【发布时间】:2025-11-22 08:50:02
【问题描述】:
免责声明:为我的愚蠢找借口,但我不是网络程序员:D
我正在尝试使用 python scrapy 编写爬虫。当我查看这个vbulletin 板时,我遇到了一些奇怪的行为。当我在 firefox 中加载页面并使用 firefox/firebug 检查它时,我看到论坛 L1 标题有 forumbit_nopost new L1 类(您可以在文档中搜索 cat117 以获取感兴趣的元素)。
当我使用 scrappy 或 curl 检索文档时,我将类设置为 forumbit_nopost old L1。我在使用 curl 时更改了用户代理以匹配 firefox 并且没有任何区别,所以我怀疑它与一些 javascript 执行有关。我已经尝试在 firefox 中禁用 javascript,但 firefox 仍然有源,它具有类属性的 new 变体。
有人可以向我解释发生了什么吗? :D
P.s.,chrome 也可以看到 old 变体。
使用 curl 命令:
curl http://forums.heroesofnewerth.com/index.php --user-agent "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0" > scratch
【问题讨论】:
-
我在 Firefox 12 和 Chrome 18 (Ubuntu 12.04) 中打开了该页面 - 我到处都是
forumbit_post old类。也许他们正在测试新的布局/引擎?只是巧合? -
wget 和 chrome 在此日期为“旧”服务。
-
你想提取什么?忽略这个问题和 xpath 到像“//h2@[class='forumtitle']/a”这样的通用内容
-
在开始浏览帖子之前,我正在尝试提取整个论坛的拓扑结构。
标签: python html screen-scraping web-crawler scrapy