C#HttpWebRequest和JavaScript的 [英] C# httpwebrequest and javascript

查看:174
本文介绍了C#HttpWebRequest和JavaScript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#的HttpWebRequest获得一个网页的一些数据。问题是,一些数据使用JavaScript / AJAX更新后的页面加载,我没有得到它的响应字符串。有没有办法有WebRequest的等待,直到所有的页面完成执行脚本?

I am using C# HttpWebRequest to get some data of a webpage. The problem is that some of the data is updated using javascript/ajax after the page is loaded and I am not getting it in the response string. Is there a way to have the webrequest wait untill all the scripts in the page have finished executing?

感谢

阿米特

推荐答案

如果我正确地跨preT你的问题,对于你的问题没有简单的解决方案。

If I correctly interpret your question, there is no simple solution for your problem.

正在刮从服务器和因为你的C#code不是一个真正的web浏览器,它不执行客户端脚本的HTML。

You are scraping the HTML from a server and since your C# code is not a real web browser, it doesn't execute client scripts.

这样,您就不能访问的信息,你取不包含HTML。

This way you can't access information which the HTML you fetch doesn't contain.

编辑:我不知道这些AJAX从原来的网站有多么复杂要求的,但你可以使用萤火虫或提琴手的IE,看看如何将请求作出以调用这些在C#应用程序AJAX调用了。所以,你可以添加你需要的信息碎片。但是,这只是一种理论上的解决方案。

I don't know how complex these AJAX calls from the original web site are, but you could use Firebug or Fiddler for IE to see how the requests are made in order to call these AJAX calls in your C# application too. So you could add the pieces of information you'll need. But it's only a theoretical solution.

这篇关于C#HttpWebRequest和JavaScript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆