爬取猎聘python_爬取前程无忧大数据岗位相关信息--Python
时间: 2023-12-29 12:04:42 浏览: 114
好的,以下是爬取猎聘python和前程无忧大数据岗位相关信息的Python代码:
## 爬取猎聘python岗位信息
```python
import requests
from bs4 import BeautifulSoup
url = 'https://www.liepin.com/zhaopin/?key=python'
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.36 Edge/16.16299'
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
job_list = soup.find_all('div', class_='job-info')
for job in job_list:
job_name = job.find('a', class_='job-name').text.strip()
job_salary = job.find('span', class_='text-warning').text.strip()
job_company = job.find('a', class_='company-name').text.strip()
job_location = job.find('span', class_='area').text.strip()
job_time = job.find('span', class_='time-info').text.strip()
print('职位名称:', job_name)
print('薪资待遇:', job_salary)
print('公司名称:', job_company)
print('工作地点:', job_location)
print('发布时间:', job_time)
print('------------------------')
```
## 爬取前程无忧大数据岗位信息
```python
import requests
from bs4 import BeautifulSoup
url = 'https://search.51job.com/list/000000,000000,0000,00,9,99,大数据,2,1.html'
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.36 Edge/16.16299'
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
job_list = soup.select('.el')
for job in job_list[1:]:
job_name = job.select('.t1')[0].text.strip()
job_company = job.select('.t2')[0].text.strip()
job_location = job.select('.t3')[0].text.strip()
job_salary = job.select('.t4')[0].text.strip()
job_time = job.select('.t5')[0].text.strip()
print('职位名称:', job_name)
print('公司名称:', job_company)
print('工作地点:', job_location)
print('薪资待遇:', job_salary)
print('发布时间:', job_time)
print('------------------------')
```
以上代码仅供参考,具体使用时请根据自己的需求进行修改。注意爬虫的合法性,遵守相关法律法规。
阅读全文