使用 YQL 抓取 HTML

发布于 2024-11-17 20:46:47 字数 296 浏览 4 评论 0原文

我正在尝试使用 YQL 来抓取一些网站。当我在 YQL 控制台中测试各种查询时,我得到一个结果节点。例如,当我运行时:

select * from html where url="http://www.reverbnation.com/" and xpath='/html/body'

我得到一个空的 节点 (固定链接)。 提前致谢!

I am trying to use YQL to scrape some websites. When I test various queries in the YQL console I get an results node. So for example when I run:

select * from html where url="http://www.reverbnation.com/" and xpath='/html/body'

I get an empty <results /> node (permalink).
Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失与倦" 2024-11-24 20:46:47

http://www.reverbnation.com 可能会阻止来自 Yahoo! 的请求基于某些标准,例如标题。我查看了 reverbnation 的 robots.txt,他们并没有阻止 Yahoo!基于“Yahoo Pipes 2.0”用户代理,所以它一定是别的东西。

要重新创建问题,请对您自己的站点进行 YQL 查询,然后查看完整的访问日志以查看完整的请求和来自 Yahoo! 的所有标头!然后使用 cURL 等工具发出类似的请求。

您还可以尝试在端口上运行 netcat 并使用 http://yoursite.com:PORT 进行查询以查看完整的请求。

相关问题此处讨论

http://www.reverbnation.com may be blocking the request coming from Yahoo! based on certain criteria, like headers. I had a look at reverbnation's robots.txt, and they aren't blocking Yahoo! based on the "Yahoo Pipes 2.0" user agent, so it must be something else.

To re-create the issue, make a YQL query against your own site, then look at the full access logs to see the full request and all headers that came from Yahoo! Then make a similar request using a tool like cURL.

You can also try and run netcat on a port and query with http://yoursite.com:PORT to see the full request.

Related issue discussed here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文