0

我听说scrapy 不支持javascript。我想知道我是否可以使用 scrapy 使用 crawlspider 来抓取链接到我们的 Intranet 站点,我们的 Intranet 站点有 javascript,我相信它会在您单击链接时生成,但我不是 100% 确定。

但是视图源是由 xml-stylesheet 组成的,当我使用 firebug 时,它具有与 html 相同的数据。我也无法使用 html 标签来抓取网站,我需要使用 xml 标签才能抓取。我很困惑为什么它同时具有 html 和 xml 并且两者都有数据以及为什么我不能只抓取 xml 的 html?

我知道我可以使用 xml 标签抓取第一页,但我可以继续关注链接并继续抓取吗?

我仍然可以使用scrapy的crawlspider来抓取每个链接还是不能?如果我不能,你能推荐另一个我可以使用的工具吗?支持javascripts和后认证登录(https)。?

谢谢!

这是我使用 firebug 时的 HTML 数据(与 XML 相同的数据)

<tr>
<td class="crt">1</td>
<td class="listCell" align="center">
<td class="listCell" align="center">
<a href="/dis/packages.jsp?view=list&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100">probe0</a>
</td>
<td class="listCell" align="center">
<a href="/dis/packages.jsp?view=list&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100">6505550000</a>
</td>
<td class="listCell" align="center">
<a href="/dis/packages.jsp?view=timeline&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100&date=20130716T141624949">2013-07-16 14:16:24.949</a>
</td>
<td class="cell" align="center">2013-07-16 14:16:24.949</td>
<td class="cell" align="left">1 - SMS_PullRequest_CS</td>
<td class="listCell" align="right">
<a href="/dis/profile_download?profileId=4294967295">4294967295</a>
</td>
<td class="listCell" align="center">
<a href="/dis/sessions.jsp?view=list&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&mdn=6505550000&subscrbid=6505550000&maxlength=100">view sessions</a>
</td>
<td class="listCell" align="center">
<a href="/dis/errors_agg.jsp?view=list&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&mdn=6505550000&subscrbid=6505550000&maxlength=100">view errors</a>
</td>
</tr>

这是我使用查看源 XML 样式表时的数据(与 HTML 相同的数据)

<row>
<cell type="href" href="/dis/packages.jsp?view=list&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&mdn=6505550000&subscrbid=6505550000&maxlength=100">6505550000</cell>
<cell type="href" href="/dis/packages.jsp?view=list&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100">probe0</cell>
<cell type="href" href="/dis/packages.jsp?view=list&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100">6505550000</cell>
<cell type="href" href="/dis/packages.jsp?view=timeline&show=perdevice&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&subscrbid=6505550000&mdn=6505550000&maxlength=100&date=20130716T143636194">2013-07-16 14:36:36.194</cell>
<cell type="plain">2013-07-16 14:36:36.194</cell>
<cell type="plain">1 - SMS_PullRequest_CS</cell>
<cell type="href" href="/dis/profile_download?profileId=4294967295">4294967295</cell>
<cell type="href" href="/dis/sessions.jsp?view=list&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&mdn=6505550000&subscrbid=6505550000&maxlength=100">view sessions</cell>
<cell type="href" href="/dis/errors_agg.jsp?view=list&device_gid=3651746C4173775343535452414567746D75643855673D3D53564A6151624D41716D534C68395A6337634E2F62413D3D&hwdid=probe0&mdn=6505550000&subscrbid=6505550000&maxlength=100">view errors</cell>
</row>
4

2 回答 2

1

通常对于 JS,您使用将执行您的 javascript 的无头浏览器。带有 scrapy-splash 中间件的Splash和Selenium是那里的两个流行选择。

于 2017-08-20T01:52:30.637 回答
0

我也正在为 js 抓取而苦苦挣扎……那里有高五。

我知道scrapy是否从特定网站响应js的一种快速方法是从scrapy shell中检查。http://doc.scrapy.org/en/latest/topics/shell.html 你可以通过view(response)查看scrapy是如何理解你的请求url的。

例如,view(response) 不显示来自 bestbuy 的产品评论,但它可以显示 eBay 产品评论。

对于相关搜索,http://snipplr.com/all/tags/scrapy/可能会有所帮助。

如果您在此处发布您的蜘蛛,它也可能很有用。

祝你好运!解决了就给我留言!

于 2013-07-23T17:53:15.590 回答