承接国内外服务器租用托管、定制开发、网站代运营、网站seo优化托管接单、网站代更新,新老站点皆可!!咨询QQ:3787320601
当前位置:首页  >  软件开发  >  python 爬取岗位

python 爬取岗位

管理员 2023-08-29 08:00:55 软件开发 0 ℃ 0 评论 1339字 收藏

python 爬取岗位

Python是一门功能强大的编程语言,可以用它来爬取网页上的各种数据,比如我们可以用Python来爬取岗位信息,这对求职者来讲是非常有用的。

import requests
from bs4 import BeautifulSoup
def get_jobs(url):
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
jobs = soup.find_all('div', {'class': 'job'})
for job in jobs:
title = job.find('h3', {'class': 'title'}).text
company = job.find('p', {'class': 'company'}).text.strip()
location = job.find('p', {'class': 'location'}).text
salary = job.find('p', {'class': 'salary'}).text
print(f'Title: {title}\nCompany: {company}\nLocation: {location}\nSalary: {salary}\n')
if __name__ == '__main__':
url = 'https://www.xxx.com/jobs'
get_jobs(url)

在上面的代码中,我们使用了requests和BeautifulSoup这两个库,requests可以用来发送http要求,而BeautifulSoup可以用来解析html页面。

我们通过传入url参数来获得网页信息,然后使用find_all方法来找到所有的岗位信息,接着我们使用find方法来找到每一个岗位信息的标题、公司、地点和薪资。最后我们通过print方法来输出这些信息。

通过这篇文章,我们可以看到怎样使用Python来爬取岗位信息,这对求职者来讲是非常实用的。

文章来源:丸子建站

文章标题:python 爬取岗位

https://www.wanzijz.com/view/74956.html

上一篇:python 相机内参

下一篇:python 爬取疫情

TAG: php教程 centos
X

截屏,微信识别二维码

微信号:weimawl

(点击微信号复制,添加好友)

打开微信