最新Boss直聘爬虫系统(在跟~)

最新Boss直聘爬虫系统(在跟~)

BOSS直聘爬虫经常会限制IP,我们采取控制浏览器的方法获取源码爬取

例子:以爬取 杭州市 "BI"岗位为例

需要源码的v+: marshal_wz

功能1:获取对应城市的岗位页面数量

因为BOSS直聘限制了用户只能看到10页数据,所以一般需要分不同区域的来进行爬取,但是也有些区域没有该岗位,导致爬取失败;

首先查看杭州市的所有城市的区号;见博客:https://blog.csdn.net/weixin_52001949/article/details/138193474

  • 确定爬取的配置文件
  • 获取每个区域存在岗位页码的数量。方便后面遍历爬取
  • 可以看到有些地区是没有BI岗位的,最多的岗位区域是330110,余杭区

功能2:获取所有岗位详情的链接,存在本地

根据上述获取到的每个地区存在的最多页面,遍历的时候使用这个值作为最终遍历数。

python 复制代码
岗位详情链接=[]
page_start=1
page_end=2
for area in areaBusiness:
    page_start = 1
    # 获取页码值,如果没有匹配的行,则默认为None
    page_values = 对应页码表[对应页码表['城市'] == area]['页码'].values
    page_end = page_values[0] if len(page_values) > 0 else None
    if page_end is None:
        continue
    for i in range(page_start,int(page_end)+1):
        print(area, i)
        url = f'https://www.zhipin.com/web/geek/job?query={jobs[0]}&city={城市代码}&areaBusiness={code}&experience={experience}&degree={degree}'
        # 使用 Playwright 同步 API
        '获取源代码'
        boss.get(url)  
        WebDriverWait(boss, 10).until(EC.visibility_of_element_located((By.CLASS_NAME, "options-pages")))
        time.sleep(0.5)
        boss_text = boss.page_source
        soup = BeautifulSoup(boss_text, 'html.parser')
        # 找到类名为"options-pages"的<div>标签
        options_pages_div = soup.find('div', class_="options-pages")
        # 在这个<div>内部找到所有的<a>标签
        a_tags = options_pages_div.find_all('a') if options_pages_div else []
        # 从找到的<a>标签中提取文本,忽略空白和非数字内容
        numbers = [tag.text.strip() for tag in a_tags if tag.text.strip().isdigit()]
        # 获取最后一个数字,如果存在的话
        last_number = numbers[-1] if numbers else None
        job_card_left_elements = soup.find_all(class_='job-card-left')
        for element in job_card_left_elements:
            href = element['href']
            full_link = 'https://www.zhipin.com' + href
            岗位详情链接.append(full_link)
df=pd.DataFrame({
'Name':岗位详情链接})f
文件名='岗位详情链接_BI_杭州.xlsx' 
df.to_excel(f"{文件名}")

功能三:遇到需要验证,自动暂停爬取,提示需要手动验证

BOSS直聘会对任何频繁用户进行验证

我们通过控制企业微信的聊天机器人来提示用户需要验证,验证完成之后再进行爬取,基本上不到1000条数据会有提示。

具体链接到:https://blog.csdn.net/weixin_52001949/article/details/137915839?spm=1001.2014.3001.5502

python 复制代码
for i in 岗位详情链接["Name"][s:e]:
    count=count+1
    print(f"开始爬取{count}")
    # 打开网页
    url =f'{i}'
    boss.get(url)  
    time.sleep(random.uniform(10,20))
    #遇到需要验证的话执行qywx_message提示函数。
    if("点击进行验证" in boss.page_source or "您暂时无法继续访问" in boss.page_source):
        print("报错")
        count_end=count
        qywx_message()
        input()
        boss.get(url) 
        time.sleep(random.uniform(10,20))
        detail_code = boss.page_source
        '执行爬取'
        df = pd.concat([df, start_paqu(detail_code)], axis=0)
        df.to_excel(f"{文件名}_爬取到{s}-{e}.xlsx")
    else:
        detail_code = boss.page_source
        df = pd.concat([df, start_paqu(detail_code)], axis=0)
        df.to_excel(f"{文件名}_爬取到{s}-{e}.xlsx")          
相关推荐
愚公搬代码9 小时前
【愚公系列】《Python网络爬虫从入门到精通》045-Charles的SSL证书的安装
网络·爬虫·python·网络协议·ssl
cliff,11 小时前
【python爬虫】酷狗音乐爬取
笔记·爬虫·python·学习
数据小小爬虫21 小时前
利用PHP爬虫获取17网(17zwd)商品详情:实战指南
开发语言·爬虫·php
猿小猴子1 天前
Python3 爬虫 爬虫中间件
爬虫·中间件
q567315231 天前
使用Lua和lua-resty-http-simple库的爬虫程序爬取图片
爬虫·http·lua
SRC_BLUE_171 天前
[网络爬虫] 动态网页抓取 — Selenium 介绍 & 环境配置
网络·爬虫·selenium·测试工具
B站计算机毕业设计超人1 天前
计算机毕业设计Python+DeepSeek-R1大模型微博舆情分析系统 微博舆情预测 微博爬虫 微博大数 据(源码+LW文档+PPT+详细讲解)
爬虫·python·学习·算法·机器学习·毕业设计·数据可视化
朱剑君1 天前
番外篇 - Docker的使用
爬虫·docker·容器
九丶黎1 天前
爬虫案例七Python协程爬取视频
爬虫·python·音视频
HerrFu1 天前
可狱可囚的爬虫系列课程 19:静态页面和动态页面之分
爬虫·python