You need to enable JavaScript to run this app. 使用BeautifulSoup无法抓取目标行:需从student-login类提取含username/password的行
优惠活动
大模型
产品
解决方案
定价
更多

使用BeautifulSoup无法抓取目标行:需从student-login类提取含username/password的行

爬取需求与现有开发状态
  • 目标爬取页面地址:https://www.champlain.edu/current-students
  • 基础定位逻辑:在目标页面源码中查找类名为student-login的元素块
  • 进阶实现需求:在已定位的student-login元素块范围内做二次内容检索,仅返回包含username或password字符串的完整行内容
  • 当前可实现效果:现有代码可正常运行,能够输出student-login类元素块的全部内部内容,但暂未实现精准筛选逻辑,无法过滤出符合目标字符串规则的内容
  • 运行输出参考:当前代码的实际输出结果截图存储地址为https://i.sstatic.net/aGE0x.jpg,截图标注为“当前输出效果”

现有可正常运行的代码

from urllib.request import urlopen
from bs4 import BeautifulSoup

html = urlopen('https://www.champlain.edu/current-students')
bs = BeautifulSoup(html.read(), 'html.parser')
soup = bs.find(class_='student-login')

print(soup)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.05 03:54:04