
scrapy
mao_mao37
这个作者很懒,什么都没留下…
展开
-
python小爬虫,爬取文章(知乎专栏)片段
class XSSpider(scrapy.Spider): name = 'xiaoshuo' allowed_domains = ['2mcn.com'] start_urls = ['https://www.2mcn.com/html/book/73323/73323986/49627483.html'] def parse(self, response): txt = "" i_title = response.xpath("//h.原创 2020-07-20 11:07:45 · 636 阅读 · 0 评论 -
Scrapy保存中文字符到json文件时编码设置
因为测试一个网站,将获取到的内容写入json文件,在使用scrapy crawl -o file.json时,对于中文,保存的是unicode编码字符,因为需要转换为utf-8中文编码转换命令:scrapy crawl -o file.json-s FEED_EXPORT_ENCODING=UTF-8每次写命令比较麻烦,可以在settings.py中添加配置:FEED_EXPROT_ENCODING='UTF-8'这样在命令行中就不需要添加编码参数...原创 2020-07-07 10:14:14 · 1145 阅读 · 3 评论 -
使用Requests+xpath实现简单的数据爬取
最近又重新爬虫,遇到一个之前没注意的问题,就是request返回对象的问题from lxml import etree currentAllInfo = [] headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0'} sourceHtml = requests.get(url, headers=headers)原创 2020-06-09 09:07:18 · 663 阅读 · 0 评论 -
scrapy命令介绍
全局命令:Dos下输入:scrapy -hscrapy [command] [options] [args]command:命令,bench:测试本地硬件性能,测试爬虫运行环境fench:下载给定的url地址genspider:在项目下创建爬虫类runspider:运行爬虫类settiongs:获取配置信息shell:临时交互模式,来获取待访问网址信息...原创 2019-08-04 17:51:55 · 266 阅读 · 0 评论