Home > Net >  How do oneself write c # winForm, web page in the browser (such as 360 browser) and select the part
How do oneself write c # winForm, web page in the browser (such as 360 browser) and select the part

Time:10-05

Want to write a page collector, excuse me oneself write c # winForm, how to obtain a browser (e.g., 360) to select part of the web page content (text and images)?

CodePudding user response:

I now think there are two ways,
The first with a Clipboard. GetDataObject (), but this kind of method, can't get along with all the images and, and unable to get links to content (i.e. source code, htmlText),
The second use EnumWindows -- MSHTML. IHTMLDocument2, but this method can only obtain compatibility mode content, namely InternetExplorer, unable to get Chrorme speed mode?
Please everyone a great god can help me with a maze, refers to the way, thank you!

CodePudding user response:

Don't HttpWebRequest can meet you?

CodePudding user response:

Part of "selection" is what mean

CodePudding user response:

I mean, in oneself write winForm, to obtain, such as: 360 browser or qq browser, open the web page, select a want content (text or picture),

CodePudding user response:

CodePudding user response:

Like this for one paragraph contains pictures,

CodePudding user response:

The first know the address to use HttpClient or HttpWebRequest climb
Second, through the Dom to handle with the webbrowser component, this is more convenient for some,

CodePudding user response:

To use HttpWebRequest, also write the browser, from already too much trouble,
Use webbrowser component through the Dom to handle, I tried, it seems can not get 360 browser or qq browser page content (in speed mode)

CodePudding user response:

HttpWebRequest how need to write their own browser, not sending the contents of the request and then get a response, it is you want, such as download images: https://blog.csdn.net/KingCruel/article/details/53538148

CodePudding user response:

Or you install a curl, and then call c # it more simple:
https://zhidao.baidu.com/question/552246331.html

CodePudding user response:

Eldest brother, I want to write a web page is to collect small program, the purpose is in the process of the Internet, see good article, code, and so on, has the preserved, for later study, that is to say, the url is not sure, but see what oliver, collect again, so use HttpWebRequest this is not good, also is to was collected, so can only use the browser to read first, then, is net, PhD, has been used, but the author for a long time not updated, and in 64, also use a bit of a problem, so we forced to want to write a similar acquisition by program,

CodePudding user response:

Your this requirement looks be like simple, but very troublesome, if you can specify a browser, can be customized development, otherwise there are so many kinds of browser, its internal implementation principle is different, to implement the difficulty is bigger,

CodePudding user response:

360 we shall specify a browser, how to grab? Use spy++ checked the 360 browser,

Speed mode
Window handle: 985154
The Window title: Chrome Legacy Window
The name of the class: Chrome_RenderWidgetHostHWND

Compatibility mode:
Window handle: 1507940
The window title:
The name of the class: Internet Explorer_Server

CodePudding user response:

Compatibility mode, use the IE, at the moment, I can be collected, but the speed mode, also don't know how to get?

CodePudding user response:

With CEF himself by a browser, and 360 rapid mode of kernel

CodePudding user response:

Don't really have no way to obtain 360 the content of the web browser? Good depressed!!!

CodePudding user response:

The C #, and C, C + + is the big difference?

CodePudding user response:

The state of learning,,,,,,,,,,,

CodePudding user response:

The 7th floor, declare a HttpClient or HttpWebRequest (url path to write), find a a get method to a list or Table, and then you can use,

CodePudding user response:

A good learning c + + programming use

CodePudding user response:

Fetching the data using the httprequest

CodePudding user response:

The simplest way is actually the right mouse button - & gt; Copy!! Then paste in your own programs

//-- -- -- -- -- -- -- -- - the following code is one of my online copy it directly download the whole page code, work!
//-- -- -- -- -- -- -- -- -- call way as the string HTM=HttpGetPageHtml (" https://www.ip.cn ", "utf-8");
///& lt; Summary>
///get the page HTML
///& lt;/summary>
///& lt; Param name="url" & gt; The requested address & lt;/param>
///& lt; Param name="encoding" & gt; Encoding & lt;/param>
///& lt; Returns> & lt;/returns>
Public static string HttpGetPageHtml (url string, the string encoding)
{
String pageHtml=string. The Empty;
Try
{
Using (WebClient MyWebClient=new WebClient ())
{
Encoding encode=Encoding. GetEncoding (Encoding);
//determine your browser the user-agent information
//open your browser first input: about: version

MyWebClient. Headers. Add (" the user-agent ", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER ");
MyWebClient. Credentials=CredentialCache. DefaultCredentials;//get or set to the request of the Internet resources network authentication credentials
Byte [] pageData=https://bbs.csdn.net/topics/MyWebClient.DownloadData (url);//from the specified website to download data
PageHtml=encode. Get string (pageData);
}
}
The catch (Exception e)
{
Return e.M essage. ToString ();
}
Return pageHtml;
}

CodePudding user response:

Fetching the data using the httprequest

CodePudding user response:

What do you mean select contents is what

CodePudding user response:

This is a reference, just change the related code,

 using System; 

The namespace ConsoleApp2
{
Class Program
{
The static void Main (string [] args)
{
System.Net.Http.HttpClient httpClient=new System.Net.Http.HttpClient ();
HttpClient. BaseAddress=new Uri (" https://dms.esnadexpress.com/");

System.Net.Http.HttpRequestMessage httpRequestMessage=new System.Net.Http.HttpRequestMessage ();
HttpRequestMessage. Method=new System.Net.Http.HttpMethod (" GET ");
HttpRequestMessage. Headers. The Add (" context - type ", "application/PDF");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C #
  • Related