爬取http://www.hack-cn.com
2016-10-18 10:30
239 查看
#coding=utf-8 import urllib2 import re def getHtml(url): user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } req = urllib2.Request(url,headers=headers) resp=urllib2.urlopen(req) html = resp.read() pattern=re.compile('style="word-break:break-all">(.*?)</td>',re.S) items=re.findall(pattern,html) for item in items: print item return html for i in range(1,101): html = getHtml("http://www.hack-cn.com/?page=%s" %i)
相关文章推荐
- 开通新博客,欢迎大家访问:http://www.yellowwee.com.cn
- http://www.ibm.com/developerworks/cn/linux/
- http://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/
- Ajax概念(摘录自IBM http://www.ibm.com/developerworks/cn/xml/wa-ajaxintro1.html)
- 威盛 VN896 移动 PCI Express 芯片组将Vista引入笔记本平台,实现视觉完美体验http://www.viatech.com.cn/cn/products/chipsets/v-series/vn896/
- http://www.ibm.com/developerworks/cn/java/j-lo-junit-src/
- 欢迎来访我的新家:【Software MyZone】(http://www.firedragonpzy.com.cn/)
- http://www.bluecoat.com.cn/resources/overview
- http://www.taskcn.com/ 任务中国有很多活接
- http://www.ibm.com/developerworks/cn/linux/theme/kernel/index.html
- QQ在Vista下蓝屏的临时解决方案(转自http://www.beareyes.com.cn/2/lib/200612/26/20061226475.htm)
- 我的博客搬家了! 新地址:http://www.cnblogs.com/jubincn/
- OA厂商风云榜点评 (http://www.enet.com.cn)
- http://www.tupwk.com.cn
- http://www.ibm.com/developerworks/cn/web/wa-lo-firefox-ext/index.html
- http://www.techtarget.com.cn/
- 云 实例 之 http://www.salesforce.com/cn/
- A nice innovative gift site: http://www.patent-cn.com
- Web 2.0 浏览器端可靠性测试,第 2 部分: 如何发现和分析 Web 2.0 浏览器端的内存泄漏 --http://www.ibm.com/developerworks/cn/web/
- google.com,google.cn 页面跳转到 http://www.google.com.hk