1 Star 0 Fork 0

wgl/python_papapa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
齐鲁人才网.py 2.27 KB
一键复制 编辑 原始数据 按行查看 历史
1 提交于 2023-11-29 11:57 . two
import re
import requests
from bs4 import BeautifulSoup
import csv
f=open('gangwei.csv','w',newline='')
csvwriter=csv.writer(f)
for i in range(1,11):
print(f"正在爬取都{i}页")
url=f'https://www.qlrc.com/personal/js/search?keywords=%E6%95%B0%E6%8D%AE'
header={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
}
# header_dict = dict(header)
res=requests.get(url,headers=header)
res.encoding=res.apparent_encoding
html=res.text
soup=BeautifulSoup(html,'html.parser')
gangweis=soup.find_all('div',attrs={'class':'jobname'})
requires=soup.find_all('div',attrs={'class':'jobrequire'})
# print(gangweis)
gangWeiXinXi=[]
for i in range(len(gangweis)):
xinXi=[]
gangwei=gangweis[i].a.text.strip()
# print(gangwei)
xinXi.append(gangwei)
lianjie='https://www.qlrc.com/'+gangweis[i].a['href']
xinXi.append(lianjie)
require=requires[i].children
for j in require:
text=j.text.replace(' ','')
# print(text)
if len(text)>0:
xinXi.append(text)
gangWeiXinXi.append(xinXi)
for i in range(len(gangWeiXinXi)):
url1=gangWeiXinXi[i][1]
res1=requests.get(url1,headers=header)
res.encoding=res1.apparent_encoding
html1=res1.text
obj=re.compile(r'<p class="text-content" data-v-\w{8}>(?P<gangweijieshao>.*?)</p>')
result1 = obj.finditer(html1)
for item1 in result1:
gangWeiXinXi[i].append(item1.group('gangweijieshao'))
# print(url1)
for info in gangWeiXinXi:
gangwei_name=info[0]
gangwei_lianjie=info[1]
gangwei_xinzi=info[2]
gangwei_dizhi=info[3]
gangwei_nianxin=info[4]
gangwei_xueli=info[5]
gangwei_zhize=info[6]
gangwei_yaoqiu=info[7]
csvwriter.writerow(
["岗位名称", "gangwei_lianjie", "gangwei_xinzi", "gangwei_dizhi", "gangwei_nianxin", "gangwei_xueli", "gangwei_zhize",
"gangwei_yaoqiu"])
csvwriter.writerow([gangwei_name,gangwei_lianjie,gangwei_xinzi,gangwei_dizhi,gangwei_nianxin,gangwei_xueli,gangwei_zhize,gangwei_yaoqiu])
f.close()
# print(gangWeiXinXi)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wgl3170669811/python_papapa.git
git@gitee.com:wgl3170669811/python_papapa.git
wgl3170669811
python_papapa
python_papapa
master

搜索帮助