import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import csv
def paQufun(a):
f = open('./data/' + a + '.csv', mode='a', encoding='utf-8', newline='')
data = csv.DictWriter(f, fieldnames=['招聘职业', '地区', '公司', '薪资', '工作经验要求', '学历要求', '工作介绍', '公司福利', '详情页'])
data.writeheader()
# 实例化浏览器
driver = webdriver.Chrome()
# driver.get('https://sou.zhaopin.com/?jl=763&kw=%E5%89%8D%E7%AB%AF')
'''
city接城市后编码
business接区编码,可不加
'''
driver.get('https://www.zhipin.com/web/geek/job?query=&city=101270100&areaBusiness=510108')
# 隐式等待
driver.implicitly_wait(50)
find = driver.find_element('css selector', ' .search-input-box .input')
driver.find_element('css selector', ' .search-input-box .input').send_keys(a)
# 点击搜索
driver.implicitly_wait(50)
driver.find_element('css selector', '.search-btn').click()
# css选择器直接定位元素
lists = driver.find_elements('css selector', '.search-job-result li.job-card-wrapper')
for li in lists:
job = li.find_element('css selector', ' .job-name').text
area = li.find_element('css selector', ' .job-area').text
company = li.find_element('css selector', ' .company-name').text
salary = li.find_element('css selector', ' .salary').text
yao = li.find_element('css selector', ' .job-info.clearfix .tag-list').text
lines = yao.split("\n")
line1 = lines[0]
line2 = lines[1]
jie = li.find_element('css selector', ' .job-card-footer.clearfix .info-desc').text
fuLi = li.find_element('css selector', ' .job-card-footer.clearfix .tag-list').text
href = li.find_element('css selector', ' .job-card-left').get_attribute('href')
dit = {
'招聘职业': job,
'地区': area,
'公司': company,
'薪资': salary,
'工作经验要求': line1,
'学历要求': line2,
'工作介绍': jie,
'公司福利': fuLi,
'详情页': href,
}
data.writerow(dit)
print(job, area, company)
print(salary, line1, line2, jie, fuLi, href)
print('\n')
24.1.26-招聘网站简单爬虫程序
需积分: 5 153 浏览量
2024-01-28
15:16:03
上传
评论
收藏 53KB ZIP 举报
![avatar](https://profile-avatar.csdnimg.cn/6b2e175507a5405cbf7e242f73673023_linghyu.jpg!1)
linghyu
- 粉丝: 567
- 资源: 15
最新资源
- 三峡职业技术学院的GeoJSON地图区域数据
- 华为HCIA-WLAN 3.0 课程视频(18 华为VRP系统概述(上).mp4)
- 编程实战项目:基于asp.net技术的学生成绩管理系统(最全的源代码+最全的文档)
- 华为HCIA-WLAN 3.0 课程视频(17 Wi-Fi6产品介绍(2).mp4)
- elasticSearch-安装.pdf
- base.apk.1.1.1.1.1.1
- 华为HCIA-WLAN 3.0 课程视频(16 Wi-Fi6产品介绍(1).mp4)
- 华为HCIA-WLAN 3.0 课程视频(15 Wi-Fi6技术介绍.mp4)
- 如何创建一个新的Docker镜像和启动应用?
- 数值分析第一题高斯解法.py
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)