最简单的python 爬虫
来源:互联网 发布:淘宝商家怎么交保证金 编辑:程序博客网 时间:2024/06/06 03:42
C:\Users\IBM_ADMIN>python -V
Python 2.7.13
查Python 工资的网站 :
http://www.jobui.com/salary/%E5%8C%97%E4%BA%AC-python%E5%B7%A5%E7%A8%8B%E5%B8%88/
# -*- coding:utf-8 -*-import re,urllib2url = 'http://daily.zhihu.com/'headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6)Gecko/20091201 Firefox/3.5.6'}#https://v.qq.com/x/page/w05097k8olz.htmldef getHtml(url): request = urllib2.Request(url,headers=headers) response = urllib2.urlopen(request) content = response.read() #print content return contenthtml = getHtml(url) def getUrls(html): pattern = re.compile('<a href="/story/(.*?)"') items = re.findall(pattern,html) allUrls=[] for it in items: allUrls.append(url+'story/'+it) return allUrls urls = getUrls(html)def getContent(urls): patternTitle=re.compile('<h1 class="headline-title">(.*?)</h1>') patternContent = re.compile('<div class="content">\\n<p>(.*?)</p>\\n</div>',re.S)# 匹配换行 for url in urls: html = getHtml(url) item =re.findall(patternTitle,html) print '-----------------------------------------'+'-----------------------------------------' print '-----------------------------------------'+'-----------------------------------------' print '***************'+item[0]+'***************' print '-----------------------------------------'+'-----------------------------------------' content = re.findall(patternContent,html) for con in content: print con #print content[0] getContent(urls)# remove unneeded things ----> 祛杂质def characterProcessing(content): pattern = re.compile('<p>(.*?)</p>'|'<li>(.*?)</li>') pass
阅读全文
0 0
- 最简单的python爬虫
- python最简单的爬虫
- 最简单的python 爬虫
- python 3 最简单的小爬虫
- Python 3.0最简单的爬虫
- 最简单的Python网页爬虫
- Python 3.0最简单的爬虫
- python最简单的小爬虫
- python爬虫——写出最简单的网页爬虫
- Python简单的爬虫
- 简单的python爬虫
- 简单的Python 爬虫
- Python网络爬虫4 ---- Linux下编写最简单的scrapy网络爬虫项目
- python 爬虫试手,好简单的爬虫
- PYTHON 爬虫简单的认识
- python简单的爬虫代码
- [python]简单的网络爬虫
- Python实现简单的爬虫
- 基于XILINX FPGA的卷积神经网络(三)
- PAT L2-022 重排链表 (deque双向队列)
- 【HDU 1950】 Bridging signals (最长上升子序列nlogn算法)(二分,动态规划)
- 【CUGBACM15级BC第16场 A】Revenge of Segment Tree
- awk详解(1)
- 最简单的python 爬虫
- myeclipse 导入 play项目
- 递归问题学习三之生成指定字符串的全排序
- 【NOIP2017】Day7
- Centos 7安装 pgplot
- 数据结构与算法之动态规划
- Java注解
- java转型
- spring中 shiro logout 配置方式