You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python实现从URL列表中筛选含特定关键词的URL

解决方案

问题需求

爬取网页URL列表后,筛选出包含“decision-makers”的链接(注:当前示例输出中的链接拼写为decidion-makers,若为笔误可自行调整判断字符串)。

修改后的代码

src = driver.page_source
 
# 使用BeautifulSoup解析
soup = BeautifulSoup(src, 'lxml')
for a in soup.find_all('a', href=True):
    # 筛选包含目标字符串的URL
    if 'decision-makers' in a['href']:
        print(a['href'])

说明

在原遍历逻辑中增加判断条件,仅当链接href属性包含指定字符串时才输出,即可得到符合要求的结果。

期望输出

https://www.linkedin.com/jobs/?decidion-makers

内容的提问来源于stack exchange,提问作者Sushmitha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 07:18:13