python爬虫智联招聘大数据技术相关专业
时间: 2023-12-21 11:05:02 浏览: 147
```python
# 爬取智联招聘大数据技术相关专业的职位信息
import requests
from bs4 import BeautifulSoup
# 设置请求头,模拟浏览器访问
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
# 发起请求
url = 'https://www.zhaopin.com/'
response = requests.get(url, headers=headers)
# 解析网页内容
soup = BeautifulSoup(response.text, 'html.parser')
# 定位搜索框并输入关键词“大数据”
search_box = soup.find('input', {'id': 'search_input'})
search_box['value'] = '大数据'
# 提交搜索请求
search_button = soup.find('button', {'class': 'doSearch'})
search_result = requests.get(url, headers=headers, params={'kw': '大数据'})
# 解析搜索结果页面
search_soup = BeautifulSoup(search_result.text, 'html.parser')
# 定位职位信息
job_list = search_soup.find_all('div', {'class': 'contentpile__content__wrapper'})
# 提取职位名称,企业名称,薪资等信息
for job in job_list:
job_title = job.find('span', {'class': 'contentpile__content__wrapper__item__info__box__jobname__title'}).text
company_name = job.find('div', {'class': 'contentpile__content__wrapper__item__info__box__cname__title'}).text
salary = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__job__saray'}).text
location = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__job__demand'}).text
education = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__job__demand'}).text
experience = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__job__demand'}).text
company_size = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__comdec__comsize'}).text
company_type = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__comdec__comtype'}).text
job_type = job.find('p', {'class': 'contentpile__content__wrapper__item__info__box__job__tags'}).text
detail_link = job.find('a', {'class': 'contentpile__content__wrapper__item__info__box__jobname__title'})['href']
print(f"职位名称:{job_title}\n企业名称:{company_name}\n薪资:{salary}\n地点:{location}\n学历要求:{education}\n经验要求:{experience}\n公司规模:{company_size}\n公司性质:{company_type}\n工作类型:{job_type}\n详情页链接:{detail_link}\n")
```
阅读全文