以下是使用bs4库爬取猎聘网站招聘项目经理职位的薪资信息的Python代码:

import requests
from bs4 import BeautifulSoup

url = 'https://www.liepin.com/zhaopin/?industries=&subIndustry=&dqs=&salary=&jobKind=&pubTime=&compkind=&compscale=&industryType=&searchType=1&clean_condition=&isAnalysis=&init=-1&sortFlag=15&flushckid=0&fromSearchBtn=2&headckid=4c4ec4f7d8a3f3e1&d_headId=2a7a8df2d2c7f713f09a404a7f8d9a9e&d_ckId=2a7a8df2d2c7f713f09a404a7f8d9a9e&d_sfrom=search_prime&d_curPage=0&d_pageSize=40&siTag=1RrOQ2c6L1zWmX8YvOJzGQ~F5FSJAXvy3qzYpXC-yoGw&key=%E9%A1%B9%E7%9B%AE%E7%BB%8F%E7%90%86'

response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')

job_items = soup.find_all('div', class_='job-info')

for job_item in job_items:
    job_title = job_item.find('a', class_='job-name').get_text().strip()
    salary = job_item.find('p', class_='text-warning').get_text().strip()
    print(f'{job_title}: {salary}')

该代码首先从猎聘网站的搜索结果页面获取所有招聘项目经理职位的HTML内容,然后使用BeautifulSoup库解析HTML内容。接着,使用find_all()方法找到所有class为"job-info"的div元素,遍历每个元素,分别从中抽取职位名称和薪资信息,并输出到控制台上

使用bs4库写一段python 代码爬取猎聘网站招聘项目经理职位的薪资信息

原文地址: https://www.cveoy.top/t/topic/cSZu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录