python 爬虫
来源:互联网 发布:手机网络gsm cdma lte 编辑:程序博客网 时间:2024/06/05 10:44
python 爬虫课程
安装下载版本(https://www.python.org/downloads/release/python-2712/)
默认会安装到C:\Python27目录下,配置环境变量Path
命令提示符测试 ,python
如下问题,环境变量未配置
‘python’不是内部或外部命令,也不是可运行的程序或批处理文件。
1.爬虫简介
2.简单爬虫架构
3.URL管理器
4.网页下载器(urllib2)
5.网页解析器(beautifulSoup)
6.爬取百度百科Python词条相关的数据
简介
- python 爬虫意思:自动访问互联网自动提取数据
- 互联网数据,为我所用!
简单爬虫架构
- 爬虫调度端:监视状况.
URL管理器
URL管理器:管理待抓取URL集合和已抓取URL集合
–防止重复抓取,防止循环抓取
URL实现方式
网页下载器(urllib2)
import urllib2, cookieliburl ="https://www.baidu.com/"print "one"response1=urllib2.urlopen(url)print response1.getcode()print len(response1.read())
print "two"request=urllib2.Request(url);request.add_header("user-agent","Mozilla/5.0")response2=urllib2.urlopen(url)print response2.getcode()print len(response2.read())
print "three"cj=cookielib.CookieJar()opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))urllib2.install_opener(opener)response3=urllib2.urlopen(url)print response3.getcode()print len(response3.read())
在Eclipse中安装pydev插件
http://www.cnblogs.com/Bonker/p/3584707.html
启动Eclipse, 点击Help->Install New Software… 在弹出的对话框中,点Add 按钮。 Name中填:Pydev, Location中填http://pydev.org/updates
然后一步一步装下去。 如果装的过程中,报错了。 就重新装。
阅读全文
0 0
- python爬虫-->爬虫基础
- [爬虫] Python爬虫技巧
- Python爬虫
- python 爬虫
- python 爬虫
- python 爬虫
- python爬虫
- Python爬虫
- Python爬虫
- python 爬虫
- Python爬虫
- python爬虫
- python 爬虫
- python 爬虫
- python爬虫
- python爬虫
- python爬虫
- python 爬虫
- C语言指针基础预习
- python之导入os
- 计蒜客 跳跃游戏二
- RxJava 中的map与flatMap
- Java时间串获取
- python 爬虫
- 【笔记】《WebGL编程指南》学习-第8章光照(3-点光源光)
- python 字符串操作
- 关于(最长链)的模板题
- java md5加密
- week3 C语言练习
- 找数字串:找出字符串中连续最长的数字串
- 使用Eclipse编译运行MapReduce程序 Hadoop2.6.0_Ubuntu/CentOS
- 对于sql字段非空但插入值为空,将值转换为空的字符串