Demand is: Go to a website to capture the query results. Environment is VB.NET
Starting from 0, the specific stuff in the .NET is unclear, so I will search. It is Google, and it is Baidu, Yisou ... The content of the hos. NET IE, split web .NET, embedd IE, etc. Didn't you learn about WebBrowser controls.
Among them, there is a big article in helping me is http://www.microsoft.com/china/msdn/archives/Workshop/Scrape.asp
It's just a VB environment introduced here. There is nothing difference to .Net, don't laugh! I started looking for SHDOCVW.DLL and MSHTML.DLL to add a half-day strength. Because everyone said WebBrowser. And .NET The Microsoft Web Browser..
Practice first in the above article!
Don't say nonsense.
Be first to do an input box, and a button for input information, and submit information.
Write in the Click event of the button:
DIM PostData as string () = {"searchtext =" me.searchtext.text} DIM STRURL AS STRING = "http: //" DIM sessionhtml as string = postdate (strurl, postdata) "Generate Temporary Document DIM SW AS streamwriter = New StreamWriter ("D: /1.htm", False, Encoding.Getencoding ("GB2312")) SW.WRITELINE (SessionHtml) sw.close () me.axwebbrowserfill.navigate ("D: /1.htm")
The PostDate function is as follows:
Public Function PostDate (byval url as string, byval postdata () AS String) AS STRING
DIM POST AS STRING = "" 'stitching into a conveying variable for Each S AS String in PostData Post = S "&" Next Post = post.substring (0, Post.Length - 1) DIM HTML AS STRING = ""
Dim encoding As Encoding = encoding.GetEncoding ( "GB2312") Dim data As Byte () = encoding.GetBytes (Post) Dim myRequest As HttpWebRequest = CType (WebRequest.Create (url), HttpWebRequest) myRequest.Method = "post" myRequest .ContentType = "application / x-www-form-urlencoded" 'myRequest.ContentType = "text / asp" myRequest.ContentLength = data.Length Dim newStream As Stream = myRequest.GetRequestStream () newStream.Write (data, 0, data .Length) newStream.Close () Dim resp As HttpWebResponse = CType (myRequest.GetResponse (), HttpWebResponse) Dim sr As StreamReader = New StreamReader (resp.GetResponseStream (), System.Text.Encoding.GetEncoding ( "GB2312")) 'Return to HTML code string HTML = sr.readToEnd () sr.close () Return HTMLEND FUNCTION
that's it.
As for the display of HTML in the WebBrowser control, it is not a Delphi approach to the Internet. And .NET does not seem to have a perfect solution.
I have tried:
'AxWebBrowserFill.Navigate (SessionHtml)' Me.AxWebBrowserFill.Document.write (SessionHtml "haga") 'Me.axScriptLet.url = "about: blank" SessionHtml' Me.AxWebBrowserFill.Document.write (SessionHtml) 'doc = Me.axwebbrowserfill.Document 'doc.body.innerhtml = sessionhtml' Doc.write (sessionhtml)
It is often just the first success, and the intermediate will involve the problem of double quotes within HTML.
There are also online, as follows:
'Field in the report display in WebBrowser' Dim doc As IHTMLDocument2 = CType (AxWebBrowserFill.Document, IHTMLDocument2) 'Dim bodyElement As IHTMLElement = CType (doc.body, IHTMLElement)' 'bodyElement.innerHTML = SessionHtml "haga" and this Method I have not played!