最新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")          
相关推荐
疏狂难除44 分钟前
【Tauri2】050——加载html和rust爬虫
开发语言·爬虫·rust·spiderdemo
B站_计算机毕业设计之家10 小时前
python电商商品评论数据分析可视化系统 爬虫 数据采集 Flask框架 NLP情感分析 LDA主题分析 Bayes评论分类(源码) ✅
大数据·hadoop·爬虫·python·算法·数据分析·1024程序员节
dont worry about it15 小时前
使用亮数据爬虫API零门槛快速爬取Tiktok数据
开发语言·爬虫·python
小白学大数据16 小时前
Python爬虫定时任务:自动化抓取豆瓣每日最新短评
爬虫·python·自动化
tang777891 天前
如何利用代理 IP 构建分布式爬虫系统架构?
分布式·爬虫·tcp/ip
Amo Xiang1 天前
JavaScript逆向与爬虫实战——基础篇(css反爬之动态字体实现原理及绕过)
爬虫·python·js逆向·动态字体
电商API_180079052472 天前
微店常用API:获取商品详情接口|关键字搜索商品接口|获取快递费接口-打通商品运营与用户体验的技术桥梁
大数据·服务器·人工智能·爬虫·数据挖掘
绒绒毛毛雨2 天前
爬虫前奏--基于macos的ip代理池构建
爬虫·tcp/ip·macos
B站_计算机毕业设计之家3 天前
基于大数据的短视频数据分析系统 Spark哔哩哔哩视频数据分析可视化系统 Hadoop大数据技术 情感分析 舆情分析 爬虫 推荐系统 协同过滤推荐算法 ✅
大数据·hadoop·爬虫·spark·音视频·短视频·1024程序员节
一晌小贪欢3 天前
Python爬虫第10课:分布式爬虫架构与Scrapy-Redis
分布式·爬虫·python·网络爬虫·python爬虫·python3