51JOB网站爬虫

2024-01-08 05:20
文章标签 网站 爬虫 51job

本文主要是介绍51JOB网站爬虫,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

关于51job网站的爬虫

    • 一、原由
    • 二、查看51job网站内容
    • 三、部分代码展示
    • 四、效果展示

一、原由

学校里有要求每日收集相应就业信息内容

二、查看51job网站内容

三、部分代码展示

def create_excel(excel_data):localtime = time.localtime(time.time())name = str(localtime.tm_mon) + str(localtime.tm_mday) + college + ".xlsx"app = xw.App(visible=True, add_book=False)# 新建工作簿wb = app.books.add()# 存储excel# wb.save('example.xlsx')# 引用工作表sht = wb.sheets['sheet1']sht.range('A1').options(expand='table').value = excel_dataprint(sht.range('A1').value)wb.save(name)# 退出工作簿wb.close()# 推出excelapp.quit()returndef write_excel(excels):for excel in excels:for word in excel:print(word)return# 上海 软件工程
def get_html(job_pos, search):target_url = get_url(job_pos, 3, urllib.parse.quote(search))print(target_url)response = request.urlopen(target_url)html_doc = response.read().decode('gbk')soup = BeautifulSoup(html_doc, 'html.parser')div_test = soup.find_all("script")# div_test = div_test.find_all("script")# print(div_test)ans = re.findall(r"window.__SEARCH_RESULT__\s=\s({.*})", div_test.__str__())ans = re.findall(r"job_href\":\"(https:[^\"]*t=0)", ans[0])for an in ans:job_list.append(str(an).replace("\\", ""))return job_list# 收集职业就业网页信息
def get_information(aim_websites):i = 1job_information_list.append(type_table)for website in aim_websites:job_information = []if i == 11:break# "https://jobs.51job.com/shanghai-ypq/125300004.html?s=01&t=0"response = request.urlopen(website)html_doc = response.read().decode('gbk')# print(html_doc)soup = BeautifulSoup(html_doc, 'html.parser')# 输出公司名字company_name = soup.find(class_="com_msg").p['title']# 输出公司类型company_type = soup.find(class_="com_tag").p['title']# 输出招聘信息cn = soup.find(class_="cn")job_name = cn.h1['title']stuff_info = soup.find(class_="cn").find(class_="msg ltype")['title']ans = stuff_info.split("|")# 生成相应内容detail = []aim_create.append(type_table)for an in ans:detail.append(str(an).replace(u'\xa0', u''))print('--------------------' + str(i) + '----------------------')# 序号# print("序号:")job_information.append(i)i += 1# 类别# print("类别:")job_information.append(college)# 创建时间# print("创建时间:")localtime = time.localtime(time.time())name = str(localtime.tm_year) + '/' + str(localtime.tm_mon) + '/' + str(localtime.tm_mday)job_information.append(name)# 过期时间# print("过期时间:")job_information.append('')# 工作地点# print("工作地点:" + job_list[1])job_information.append(detail[0])# 公司名称# print("公司名称:" + company_name)job_information.append(company_name)# 链接地址# print("链接地址:")job_information.append(website)# 职务名称# print("职务名称:" + job_name)job_information.append(job_name)# 是否推荐job_information.append('')# 公司性质job_information.append(company_type)# 职务性质job_information.append('实习')# 教育背景# print("教育背景" + job_list[2])job_information.append(detail[2])# 信用良好# print("信用良好:" + '1')job_information.append('1')# 不良信用# print("不良信用")job_information.append('')# 500强# print("500强")job_information.append('')# 上市# print("上市")job_information.append('')# 200人以上# print("200人以上")job_information.append('1')# 200人以下# print("200人以下")job_information.append('')# 岗位数# print("岗位数:" + '1')job_information.append('1')# 需求人数# print("需求数:" + job_list[3])job_information.append(detail[3])job_information_list.append(job_information.copy())return job_information_listdef get_pos():return# 生成搜索接口
def get_url(pos_name, num, search):postion = pos[pos_name]num = company_size[3]target = url + "/list/"+postion+",000000,0000,00,9,99,"+urllib.parse.quote(search)+",2,1.html?lang=c&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize="+num+"&ord_field=0&dibiaoid=0&line=&welfare="return targetdef turn_page(source):ans_list = []for i in range(1, 10):ans = re.sub(r',(\d*).html', "," + str(i) + ".html", source)ans_list.append(ans)return ans_listdef position(chars):string = ""for char in chars:string = char + ""return stringdef to_unicode(string):ret = ''for v in string:ret = ret + hex(ord(v)).upper().replace('0X', '\\u')return ret

四、效果展示

在这里插入图片描述
部分内容有误 需求人数/教育背景/发布时间有误,由于本身位置有误(有待改进)

这篇关于51JOB网站爬虫的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/582448

相关文章

如何关闭Mac的Safari通知? 3招教你关闭Safari浏览器网站通知的技巧

《如何关闭Mac的Safari通知?3招教你关闭Safari浏览器网站通知的技巧》当我们在使用Mac电脑专注做一件事情的时候,总是会被一些消息推送通知所打扰,这时候,我们就希望关闭这些烦人的Mac通... Safari 浏览器的「通知」功能本意是为了方便用户及时获取最新资讯,但很容易被一些网站滥用,导致我们

Web技术与Nginx网站环境部署教程

《Web技术与Nginx网站环境部署教程》:本文主要介绍Web技术与Nginx网站环境部署教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Web基础1.域名系统DNS2.Hosts文件3.DNS4.域名注册二.网页与html1.网页概述2.HTML概述3.

Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)

《Python爬虫selenium验证之中文识别点选+图片验证码案例(最新推荐)》本文介绍了如何使用Python和Selenium结合ddddocr库实现图片验证码的识别和点击功能,感兴趣的朋友一起看... 目录1.获取图片2.目标识别3.背景坐标识别3.1 ddddocr3.2 打码平台4.坐标点击5.图

nginx部署https网站的实现步骤(亲测)

《nginx部署https网站的实现步骤(亲测)》本文详细介绍了使用Nginx在保持与http服务兼容的情况下部署HTTPS,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值... 目录步骤 1:安装 Nginx步骤 2:获取 SSL 证书步骤 3:手动配置 Nginx步骤 4:测

Python3 BeautifulSoup爬虫 POJ自动提交

POJ 提交代码采用Base64加密方式 import http.cookiejarimport loggingimport urllib.parseimport urllib.requestimport base64from bs4 import BeautifulSoupfrom submitcode import SubmitCodeclass SubmitPoj():de

速盾高防cdn是怎么解决网站攻击的?

速盾高防CDN是一种基于云计算技术的网络安全解决方案,可以有效地保护网站免受各种网络攻击的威胁。它通过在全球多个节点部署服务器,将网站内容缓存到这些服务器上,并通过智能路由技术将用户的请求引导到最近的服务器上,以提供更快的访问速度和更好的网络性能。 速盾高防CDN主要采用以下几种方式来解决网站攻击: 分布式拒绝服务攻击(DDoS)防护:DDoS攻击是一种常见的网络攻击手段,攻击者通过向目标网

Python:豆瓣电影商业数据分析-爬取全数据【附带爬虫豆瓣,数据处理过程,数据分析,可视化,以及完整PPT报告】

**爬取豆瓣电影信息,分析近年电影行业的发展情况** 本文是完整的数据分析展现,代码有完整版,包含豆瓣电影爬取的具体方式【附带爬虫豆瓣,数据处理过程,数据分析,可视化,以及完整PPT报告】   最近MBA在学习《商业数据分析》,大实训作业给了数据要进行数据分析,所以先拿豆瓣电影练练手,网络上爬取豆瓣电影TOP250较多,但对于豆瓣电影全数据的爬取教程很少,所以我自己做一版。 目

49个权威的网上学习资源网站

艺术与音乐 Dave Conservatoire — 一个完全免费的音乐学习网站,口号是“让每一个人都可以接受世界级的音乐教育”,有视频,有练习。 Drawspace — 如果你想学习绘画,或者提高自己的绘画技能,就来Drawspace吧。 Justin Guitar — 超过800节免费的吉他课程,有自己的app,还有电子书、DVD等实用内容。 数学,数据科学与工程 Codecad

BT天堂网站挂马事件后续:“大灰狼”远控木马分析及幕后真凶调查

9月初安全团队披露bt天堂网站挂马事件,该网站被利用IE神洞CVE-2014-6332挂马,如果用户没有打补丁或开启安全软件防护,电脑会自动下载执行大灰狼远控木马程序。 鉴于bt天堂电影下载网站访问量巨大,此次挂马事件受害者甚众,安全团队专门针对该木马进行严密监控,并对其幕后真凶进行了深入调查。 一、“大灰狼”的伪装 以下是10月30日一天内大灰狼远控的木马样本截图,可以看到该木马变种数量不

PHP抓取网站图片脚本

方法一: <?phpheader("Content-type:image/jpeg"); class download_image{function read_url($str) { $file=fopen($str,"r");$result = ''; while(!feof($file)) { $result.=fgets($file,9999); } fclose($file); re