C#HttpWebRequest返回不完整的HTML [英] C# HttpWebRequest returns incomplete HTML

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

问题描述

大家好,


我正在用C#编写一个应用程序,它将进行一些网页抓取。我已经有了相当多的expierence,但我遇到了一个问题,我从页面上得到了返回的HTML。


当我查看页面我试图在网站上抓一切都很好,我可以在页面底部看到服务部分,但是当我在页面上查看视图源时,缺少相应的代码页面的那一部分。我已经意识到原因可能是页面上有一个JavaScript函数,其中服务部分应该是。这是代码:

Hi All,

I''m writing an app in C# that will be doing a bit of web scraping. I''ve got a fair bit of expierence with this but i''ve come across an issue with the returned HTML i''m getting from the pages.

When i view the page i''m trying to scrape in a website all is well, and i can see a ''Services'' section on the bottom of the page, however when i do a view source on the page, the corresponding code is missing for that part of the page. I''ve realised that the reason may be that on the page there is a JavaScript function where the ''Services'' section should be. Here is the code:

展开 | 选择 | Wrap | 行号

推荐答案

好的,


我现在发现我不能做我需要做的HttpWebRequest,因为它只是一个请求,因为我想要执行的JavaScript我需要某种类型客户端技术。


所以现在我正在使用WebBrowser控件,这里没有任何问题,除了源代码以外我什么都得不到。


我如何获得用于di的所有HTML张开页面?


非常感谢!


Andy
OK,

I''ve now discovered that i can''t do what i need to do with HttpWebRequest, as it''s just a request, as i want the JavaScript executed i''m gona need some sort of client side technology.

So now i''m tyring to use the WebBrowser control, no problems here except again i can''t get anything other than the source code.

How do i get all the HTML that is used to display the page?

Help much appreciated!

Andy


也许试试WebBrowser.Document
Perhaps try WebBrowser.Document


谢谢,


我已经尝试了webBroswer.DocumentText,但我没有得到屏幕上的内容,我只是获取源代码。


如果有人能解释我是如何以html格式获得屏幕输出而不仅仅是源代码非常感谢它!
Thanks,

I''ve tried webBroswer.DocumentText but i''m not getting what is on screen, i''m just getting the source code.

If someone could explain how i get the screen output in html form rather than just the source code would very much appreciate it!


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

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