摘要: import repattern=re.compile('要匹配的文字')a=pattern.match('被匹配')a# True or Falsefindter方法import rea=re.finter(patrern,strings)#返回一个group对象a,其中按顺序包含了 匹配成功的字... 阅读全文
posted @ 2015-03-25 21:19 hitz&x 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 下载百度贴吧连续几页的帖子# -*- coding: utf-8 -*-"""Created on Sun Mar 22 18:53:43 2015@author: Administrator"""# -*- coding: utf-8 -*-#---------------------------... 阅读全文
posted @ 2015-03-25 19:46 hitz&x 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 10.伪装成浏览器访问 某些网站反感爬虫的到访,于是对爬虫一律拒绝请求 这时候我们需要伪装成浏览器,这可以通过修改http包中的header来实现 headers={'User-Agent':'Mozilla/5.0(Windows;U;WindowsNT6.1;en-US;rv:1.9.1.6)G... 阅读全文
posted @ 2015-03-25 18:38 hitz&x 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 填写表单import urllib2import urllibpostdata=urllib.urlencode({ #需要填写的项'username':'zhangxu','password':'zx199551','continueURI':'http://www.verycd.com/','f... 阅读全文
posted @ 2015-03-25 17:43 hitz&x 阅读(149) 评论(0) 推荐(0) 编辑