使用 YQL 抓取 HTML
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.