单线程爬虫
来源:互联网 发布:苹果抹除数据后会怎样 编辑:程序博客网 时间:2024/06/07 01:34
单线程爬虫
Requests:HTTP for Humans
完美替代Python的urllib2模块
更多的自动化
更友好的用户体验
更完善的功能
第三方库安装技巧:
少用easy_install因为只能安装不能卸载
多用pip方式安装
撞墙了,请戳 http://www.lfd.uci.edu/~gohlke/pythonlibs/
第一个网页爬虫
Requests获取网页源代码
--直接获取源代码
--修改http头获取源代码
Requests与正则表达式
使用Requests获取网页源代码,再使用正则表达式匹配出感兴趣的内容,这是单线程爬虫的基本原理。
#-*-coding:utf8-*-import requestsimport reimport sysreload(sys)sys.setdefaultencoding("gb18030")type=sys.getfilesystemencoding()# headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebkit/537.36(KHTML,like Gecko)'}headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36'}# html=requests.get('http://jp.tingroom.com/yuedu/yd300p')html=requests.get('http://jp.tingroom.com/yuedu/yd300p',headers=headers)html.encoding='utf-8'# print html.texttitle=re.findall('color:#666666;">(.*?)</span>',html.text,re.S)for each in title: print eachchinese=re.findall('color: #039;(.*?)</a>',html.text,re.S)for each in chinese: print each
阅读全文
0 0
- 单线程爬虫
- python-单线程爬虫
- 单线程爬虫
- Python爬虫之<单线程爬虫>
- Python爬虫(单线程爬虫(三))
- Python爬虫入门学习--(单线程爬虫)
- python单线程网络爬虫
- Python____初识+单线程爬虫
- python单线程爬虫(一)
- 单线程的小爬虫
- 网络爬虫单线程的实现
- python学习中一个单线程爬虫
- Python 网络爬虫单线程版
- 单线程爬虫之“中国领导干部资料库”
- Python--正则表达式/单线程网络爬虫
- python 单线程与多线程爬虫
- Python爬虫学习(单线程爬虫(一))
- Python爬虫学习(单线程爬虫(二))
- 最小路径和
- Service启动流程源码分析(一):startService
- Caffe实战系列:实现自己Caffe网络层
- 隐式的类类型转换
- R语言-数据框
- 单线程爬虫
- 学习笔记之WEB平台自定义标签库
- HDU 1016
- Css: position float display
- 洛谷 P1726 上白泽慧音
- grunt学习入门之一uglify
- [进击吧shader]深入一点的shader之Tag
- Android设计模式之——工厂方法模式
- PHP中的ob系列函数