最新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")          
相关推荐
泡泡以安11 小时前
安卓高版本HTTPS抓包:终极解决方案
爬虫·https·安卓逆向·安卓抓包
q5673152313 小时前
Java Selenium反爬虫技术方案
java·爬虫·selenium
巴里巴气1 天前
Python爬虫用Clash软件设置代理IP
爬虫·python·tcp/ip
우리帅杰10 天前
爬虫002-----urllib标准库
爬虫
RacheV+TNY26427811 天前
拼多多API限流机制破解:分布式IP池搭建与流量伪装方案
大数据·网络·人工智能·爬虫·python
我怎么又饿了呀11 天前
DataWhale-零基础络网爬虫技术(三、爬虫进阶技术)
爬虫·datawhale
network爬虫11 天前
Python异步爬虫编程技巧:从入门到高级实战指南
开发语言·爬虫·python
电商API_1800790524711 天前
实现自动胡批量抓取唯品会商品详情数据的途径分享(官方API、网页爬虫)
java·前端·爬虫·数据挖掘·网络爬虫
lynn-6611 天前
java爬虫 -jsoup的简用法
java·开发语言·爬虫
伍哥的传说11 天前
Node.js爬虫 CheerioJS ‌轻量级解析、操作和渲染HTML及XML文档
爬虫·node.js·html