瓦廷&谷歌搜索
我正在尝试使用 Watin 来解析谷歌搜索结果。 但是 watin 无法在 Google 搜索结果页面中找到元素。当我查看源代码时,这是因为该页面是通过 javascript 生成的,因此搜索结果不会以 html 形式通过网络发送。
但是,当我打开 Firebug(在 Firefox 中)时,我能够解析由 javascript 生成的 html。
有谁知道我如何让 Watin 做同样的事情,以便我能够解析结果?
谢谢 :)
I'm trying to use Watin to parse google search results.
However watin is unable to find elements i the Google Search Result page. When I view the source it's because the page is generated off javascript so the search results are not sent over the wire in html.
However when I open up Firebug (in Firefox) I am able to parse the html that gets generated by the javascript.
Does anyone know how I can get Watin to do the same so I'm able to parse the results?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 google 搜索 API 来代替吗?
http://code.google.com/apis/ajaxsearch/documentation/#fonje< /a>
Could you use the google search API instead?
http://code.google.com/apis/ajaxsearch/documentation/#fonje
这可能是一个时间问题。如果 javascript 正在生成数据,您可能会在写入数据之前检查数据。尝试在调试中运行它,逐步执行并等待,直到您知道源代码中存在这些项目,然后再使用 WatiN 进行测试。
我还建议发布代码,以便我们可以准确地看到您想要做什么。
It may be a matter of timing. If javascript is generating the data, you may be checking for your data before it is written. Try running it in debug, stepping through and waiting until you know the items exist in the source before using WatiN to test for it.
I would also suggest posting code so we can see exactly what you're trying to do.