在C#Pin中保存网页中显示的文本 [英] Save displayed text from Web Page in C# Pin

查看:90
本文介绍了在C#Pin中保存网页中显示的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我需要保存到此网站上的用户名:http://worldoftanks.eu/community/clans/500027296-BERU/#wot&mt_order_by=-name



我用WebClient,WebBrowser,SHDocVw.WebBrowser等尝试了这个,没有任何效果,因为在下载的html页面代码中没有填写那些信息,我需要什么。正如我强调的那样,他们通过AJAX或类似的方式展示。



WebBrowser有方法ShowSaveAsDialog,但我需要没有这个对话框



有人能帮助我吗?



PS抱歉我的英文不好。

Hi
I need save to file User Names from this web: http://worldoftanks.eu/community/clans/500027296-BERU/#wot&mt_order_by=-name

I have tried this with WebClient, WebBrowser, SHDocVw.WebBrowser etc. and nothing work because in downloaded html page code has not filled that informations, what I need. As I undersrand they are showing via AJAX or somethig like this.

WebBrowser has method ShowSaveAsDialog, but I need WITHOUT this dialog

Could someone help me?

P.S. Sorry for my bad english.

推荐答案

如果他们使用Ajax或其他东西并不重要。如果您提供所需的信息并且可以以任何其他方式查看,则可以在代码中执行相同的操作。



或者,也许,你不能,只是因为你的一个问题:你使用的是尝试错误的方法,而不是试图理解事情的运作方式。这种方法效率极低。我可以通过WebBrowser和SHDocVw.WebBrowser看到它 - 可以使用浏览器组件,但与问题无关。使用 WebClient 会很有意义,但更通用的工具是类 System.Net.HttpWebRequest

http://msdn.microsoft .com / zh-cn / library / system.net.httpwebrequest%28v = vs.110%29.aspx [ ^ ]。



这是您可能需要的全部。另见我过去的答案:

如何从其他网站获取数据 [ ^ ],

从网页获取特定数据 [ ^ ]。







我发现这个问题有点困难。请参阅下面的评论,关于可能的Ajax使用。



这里有一些非常不同的建议:找出并安装一些作为HTTP间谍的插件。例如,我使用Mozilla浏览器(Seamonkey,或者你可以使用Firefox),我的插件叫做HttpFox。启用并启动它。然后加载你的页面。等到你需要的列表显示出来。停止插件。查看下载的所有请求和资源。使用提供的HTTP请求,全部下载。找出你的数据所在的位置。



我刚试过它,它只显示了你引用的一个页面的数百个下载项目。嘲笑他们,找出你的数据在哪里。



使用你已有的代码在步骤中做同样的事情。我将是你工作中相当大的捷径。



-SA
It does not matter if they use Ajax or something else. If the information you need is ever provided and can be seen in any other way, you can do the same in your code.

Or, maybe, you cannot, just because of one your problem: you are using try-and-error approach instead of trying to understand how things works. Such approach is utterly inefficient. I can see it by "WebBrowser" and "SHDocVw.WebBrowser" — browser components can be used, but are irrelevant to the problem. Using WebClient would make perfect sense, but the more universal tool is the class System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx[^].

This is all you may possibly need. See also my past answers:
How to get the data from another site[^],
get specific data from web page[^].



I found that the problem is somewhat more difficult. Please see my comment below, about possible Ajax use.

Here is some very different advice: find out and install some plug-in which works as the "HTTP spy". I, for example, use a Mozilla browser (Seamonkey, or you can use Firefox), and my plug-in is called HttpFox. Enable and start it. Then load you page. Wait until the list you need is show. Stop the plug-in. See all the requests and resources downloaded. Using HTTP requests provided, download them all. Find out in which one your data resides.

I just tried it, it shows a good hundred of downloaded items for just one page you referenced. Loot at them, find out where your data is.

Do the same thing in on step, using the code you already have. I will be a considerable shortcut in your work.

—SA


这篇关于在C#Pin中保存网页中显示的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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