如何从C#获取原始页面源(未生成源)[英] How to get raw page source (not generated source) from c#

本文是小编为大家收集整理的关于如何从C#获取原始页面源(未生成源)的处理方法,想解了如何从C#获取原始页面源(未生成源)的问题怎么解决?如何从C#获取原始页面源(未生成源)问题的解决办法?如何从C#获取原始页面源(未生成源)问题的解决方案?那么可以参考本文帮助大家快速定位并解决问题,译文如有不准确的地方,大家可以切到English参考源文内容。

问题描述

目标是获取页面的原始源,我的意思是不要运行脚本或让浏览器完全格式化页面.例如:假设源是响应后<table><tr></table>,我不想获得<table><tbody><tr></tr></tbody></table>,如何通过C#代码执行此操作?

更多信息:例如,键入" view-source:http://feeds.gawker.com/kotaku/full"在浏览器的地址栏中会给您一个XML文件,但如果您只调用http://http://http://feeds.gawker.com/kotaku/full"它将渲染一个HTML页面,我想要的是XML文件.希望这很清楚.

推荐答案

这是一种方法,但还不清楚您实际想要的东西.

using(var wc = new WebClient())
{
    var source = wc.DownloadString("http://google.com");
}

其他推荐答案

如果您在渲染自己的页面时表示.您可以使用 ,或通过覆盖页面渲染.我会质疑您这样做的动机.

脚本运行客户端,因此与任何C#代码无关.

其他推荐答案

您可以使用 fiddler 以查看实际发送的内容,例如电线.

免责声明:我认为提琴手很棒

本文地址:https://www.itbaoku.cn/post/879615.html

问题描述

The goal is to get the raw source of the page, I mean do not run the scripts or let the browsers format the page at all. for example: suppose the source is <table><tr></table> after the response, I don't want get <table><tbody><tr></tr></tbody></table>, how to do this via c# code?

More info: for example, type "view-source:http://feeds.gawker.com/kotaku/full" in the browser's address bar will give u a xml file, but if you just call "http://feeds.gawker.com/kotaku/full" it will render a html page, what I want is the xml file. hope this is clear.

推荐答案

Here's one way, but it's not really clear what you actually want.

using(var wc = new WebClient())
{
    var source = wc.DownloadString("http://google.com");
}

其他推荐答案

If you mean when rendering your own page. You can get access the the raw page content using a ResponseFilter, or by overriding page render. I would question your motives for doing this though.

Scripts run client-side, so it has no bearing on any c# code.

其他推荐答案

You can use a tool such as Fiddler to see what is actually being sent over the wire.

disclaimer: I think Fiddler is amazing

查看更多