简体   繁体   English

C#Webbrowser显示您想要什么

[英]c# webbrowser show what you want

i want create small web browser , tiny and fast 我想创建小型,快速的小型Web浏览器

but i have problem , 但是我有问题

let me explain : 让我解释 :

1 - user enter site : google.com 2 - c# program get google.com 3 - find <td nowrap="" align="center"> 4 - in web browser only show that area 1-用户输入网站:google.com 2-c#程序获取google.com 3-查找<td nowrap="" align="center"> 4-在网络浏览器中仅显示该区域

i dont know where i must start , 我不知道我必须从哪里开始,

thanks 谢谢

Ok, I'm going to try answer your question, but I am deciphering as well. 好的,我将尝试回答您的问题,但是我也在解密。

  1. Create a WebBrowser control on your form. 在窗体上创建一个WebBrowser控件。 (2.0 is fine for what you need) and .Navigate("http://www.google.com"); (2.0 .Navigate("http://www.google.com");您的需求)和.Navigate("http://www.google.com");
  2. Get the source code from the Document. 从文档中获取源代码。 You can do this as follows: string source = _WebBrowser.Document.Body.OuterHtml; 您可以按照以下步骤进行操作: string source = _WebBrowser.Document.Body.OuterHtml;
  3. Use string manipulation to get to the area on the page you need. 使用字符串操作可以转到所需页面上的区域。 For instance .SubString() functions 例如.SubString()函数
  4. Save the text into a file, or stream and load it into the WebBrowser control, or replace the pages Document HTML with just the HTML you are wanting to show. 将文本保存到文件中,或流式传输并将其加载到WebBrowser控件中,或将页面Document HTML替换为仅要显示的HTML。

Okay! 好的! Looking at the comment it seems you want to request for a page using c# and show only one part of the page. 查看评论似乎您想使用c#请求页面,并且仅显示页面的一部分。 In your case its that specific <td> . 在您的情况下,其特定的<td> Please correct me if I am wrong. 如果我错了,请纠正我。

Other than what Kyle has mentioned. 除了Kyle提到的内容。 Check out HTML agility Pack . 查看HTML敏捷包 It might be of interest to you. 您可能会感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM