Python爬虫抓取多个URL写入本地文件!1. Pycharm中运行Scrapy
windows环境下cmd中通过scrapy startproject 项目名,创建scrapy项目
修改Run…中的Script path为cmdline.py文件路径F:\programs\python\Lib\site-packages\scrapy\cmdline.py
Parameters为crawl 爬虫文件名
working directory为scrapy项目所在文件夹
每次执行该run命令即可运行scrapy
2.items.py
class Csdn02Item(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
title = scrapy.Field()#标题
updatetime = scrapy.Field()#发表时间
readcount = scrapy.Field()#阅读数
author = scrapy.Field()#作者
ranking = scrapy.Field()#博客排名
curl = scrapy.Field()#博文链接
context = scrapy.Field()#博文内容
3.pipelines.py
4.自定义的爬虫代码mycsdn.py
相关文章内容简介
1
Python爬虫抓取多个URL写入本地文件
Python爬虫抓取多个URL写入本地文件!1. Pycharm中运行Scrapywindows环境下cmd中通过scrapy startproject 项目名,创建scrapy项目修改Run…中的Script path为cmdline.py文件路径F:\programs\python\Lib\site-packages\scrapy\cmdline.pyParameters为crawl 爬虫文件名working directory为scrapy项目所在文件夹每次执行该run命令即可运行scrapy2.items.pyclass Csdn02Item(scrapy.Item):# define the fields for your item here like:# name = scrapy.Field()title = scrapy.Fiel
[阅读全文]