
python
文章平均质量分 59
青阳十五
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
python爬虫01:urllib初体验
选择爬取网站为 http://www.qiushibaike.com/翻页之后我们可以看到网址变化为http://www.qiushibaike.com/8hr/page/2/?s=4908225也就是说,其page的变化决定了我们要爬取第几页糗百因此url为url = 'http://www.qiushibaike.com/8hr/page/%d/?s=4908218' %pag原创 2016-08-29 19:20:00 · 495 阅读 · 0 评论 -
python爬虫02 re模块与正则表达式
import restl="string hdsk"pa=re.compile(r'string')ma=pa.match(stl)print ma.group()结果匹配到string原创 2016-08-30 15:59:10 · 366 阅读 · 0 评论 -
爬虫03 爬取堆糖图片并保存到本地
# -*- coding: utf-8 -*-import urllibimport urllib2import rei=0page = 1url = 'http://www.duitang.com/album/?id=80174265'user_agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Fi原创 2016-08-31 12:24:43 · 1109 阅读 · 0 评论 -
爬虫04 爬取糗事百科中文段子
# -*- coding: utf-8 -*-import urllibimport urllib2import repage = 1url = 'http://www.qiushibaike.com/8hr/page/%d/?s=4908781' %pageuser_agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/2原创 2016-08-31 18:45:16 · 307 阅读 · 0 评论 -
解决UnicodeEncodeError: 'ascii' codec can't encode characters in position
将字符串写入文本时出现解决UnicodeEncodeError: 'ascii' codec can't encode characters in position解决办法:在开头加上import sysreload(sys)sys.setdefaultencoding( "utf-8" )转载 2016-09-01 11:47:05 · 8670 阅读 · 0 评论 -
爬虫05 BeautifulSoup4初体验
# -*- coding: utf-8 -*-import sysreload(sys)sys.setdefaultencoding( "utf-8" )import urllibimport urllib2import refrom bs4 import BeautifulSouppage = 1url = 'http://www.qiushibaike.com/8hr/pag原创 2016-09-01 11:48:37 · 334 阅读 · 0 评论 -
爬虫06 代码封装(以爬虫04为基础)
爬虫04的代码对于coder来说更易读些,但是对于面向对象而言还需进行封装,仅以此作为示范# -*- coding: utf-8 -*-import urllibimport urllib2import reclass QSBK: def __init__(self): self.page = 1 self.url = 'http://www原创 2016-09-01 17:11:41 · 315 阅读 · 0 评论 -
爬虫07 爬取阿里旅行特价机票
https://sjipiao.alitrip.com/cheap_flight_search.htm?tripType=0&depCityName=&depCity=&arrCityName=&arrCity=&depDate=2016-09-04&range=30&searchGapDay=3通过填写出发地和到达地以及出发日期前后多少天,我们得到网址变化https://sjipiao.原创 2016-09-01 19:26:07 · 3912 阅读 · 0 评论 -
ipython linux下安装(Ubuntu 14.04LTS)
pip安装会出现Exception:Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/lib/python原创 2016-08-30 14:08:22 · 663 阅读 · 0 评论