爬取51job的职位信息
来源:互联网 发布:汤恩伯 知乎 编辑:程序博客网 时间:2024/05/16 12:21
#!/usr/bin/python
#encoding:utf-8
#网站---源代码---python信息---匹配findall---写入文件
import urllib
import re
import sys
reload(sys)
sys.setdefaultencoding('utf-8')#输出的内容是utf-8格式
#打开源码,获取网站
i=0;
def get_content(page):
url='http://search.51job.com/jobsearch/search_result.php?fromJs=1&jobarea=000000%2C00&district=000000&funtype=0000&industrytype=00&issuedate=9&providesalary=99&keyword=java&keywordtype=2&curr_page=2&lang=c&stype=1&postchannel=0000&workyear=99&cotype=99°reefrom=99&jobterm=99&companysize=99&lonlat=0%2C0&radius=-1&ord_field=0&list_type=0&fromType=14&dibiaoid=0&confirmdate=9'.format(page)
a=urllib.urlopen(url) #打开网页
html=a.read() #读取源代码
html=html.decode('gbk') #从gbk转为unicode
# print html
return html
#匹配到正文
def get(html):
reg =re.compile(r'class="t1 ">.*?<a target="_blank" title="(.*?)".*?<span class="t2"><a target="_blank" title="(.*?)".*?<span class="t3">(.*?)</span>.*?<span class="t4">(.*?)</span>.*?<span class="t5">(.*?)</span>',re.S)
items=re.findall(reg,html)
# print items #列表list
return items
#多页,写入文件
for j in range(1,2000):
html=get_content(j) #调用获取源码
for i in get(html):
print i[0], i[1], i[2], i[3], i[4]
with open('51job.txt','a') as f:
f.write(i[0]+'\t'+i[1]+'\t'+i[2]+'\t'+i[3]+'\t'+i[4]+'\n')
f.close()
阅读全文
0 0
- 爬取51job的职位信息
- 二.selenium爬取51job任意职位信息
- 用PHP爬取51job上苏州地区的PHP职位信息
- 使用BS4爬取 51job 一页的招聘信息
- webmagic爬取职位信息,新手上路
- Python爬取网站职位信息
- 四.BeautifulSoup爬取51job任意职位并且存储到mongodb
- 简易爬虫爬取51job招聘信息
- 用Python爬取拉钩网招聘职位信息
- 爬虫:用Python爬取招聘职位信息&职位需求分析
- 51Job自动收藏职位
- Python爬虫-爬取51job.com 招聘信息并写入文件和数据库mysql
- 爬取51job的爬虫(python)
- 爬取招聘职位一
- 51Job职位搜索助手(源码)
- 51JOB上海地区java招聘职位分析
- 基于scrapy的智联职位爬取
- scrapy框架爬取51job网
- 【MIP官方博客】mip-semi-fixed 走走又停停
- UVALive-4126 AC自动机
- 一张通往计算机世界的地图
- NetworkOnMainThreadException
- 040 罗尔定理与零点定理、介值定理综合应用;柯西中值定理; 型二( f(n) (ξ) =0 )
- 爬取51job的职位信息
- request与response方法
- 欢迎使用CSDN-markdown编辑器
- 请求数据—HttpClient
- spark相关概念
- 字节转换字符
- leetcode004-Letter Combinations of a Phone Number
- 汇编(二)
- 信号量函数 :semget semop semct 分析