Use VB to access Internet

zhaozj2021-02-11  244

With VB accessing the Internet, there are many construction modules to help users create a Internet application called a Rich Client, including Visual Basic (hereinafter referred to as VB) ActiveX control collection. They provide features such as SMTP and POP mail services, FTP, NewsGroup, and web access. In addition, the automation of web access can be implemented using OLE. This article introduces you two ways to you. Embed an Active X control in the application With Crescent Internet Toolpak (Internet Toolkit) that complies with HTTP protocols, you can connect VB applications to the Web site, transfer data to the site, and get the HTML page from the site. The Crescent HTTP control does not actually display the downloaded HTML page, but the application can use page data in the form of a string. For example, if the server generates an HTML file called MyResult.html from the client request, the client application can get and download this file by Crescent Active X connection established with the server. The code segment that establishes the connection is as follows: CIHTTP1.HOSTNAME = "MyResult.myhost.com" CIHTTP1.URL = "resultS / myresult.html" CI http.parseincomingData = truecihttp1.connecttoserver Once the Active X control is connected to the server, it triggers HTTPServerConnection event. At this time, the application issues a command CIHTTP1.GET to retrieve the page specified in the U rl attribute, and then the control activates the fileclosed event to retrieve the specified page. The application reads page text with attributes of ACTI VE X attribute HTMLPageText Withtags (home page is not embedded with HTML code. The code is as follows: MyText = CIHTTP1. HTMLPageTextwithTags If you don't want to download the entire home page with a control, you can quickly scan the page data via the Packet parameter of the control PacketReceiveD event. The PacketReceived event will be activated whenever the control is accepted by the server. In addition, client applications can also extract web page data from a standard browser using the HTTP control. For example, the ACTI VEX control is established with the web behind the scenes and downloads the published pages, allowing the traditional client application to continuously receive the latest Web information, change the original content. To further simplify processing, you need to set the properties before the ActiveX control is connected to the web page. Crescent's HTTP control can also add the URL address of the download page, the address of the image file, and all HTML command files to the specified three list boxes, respectively. Using OLE to implement web access, in addition to the ActiveX control, there is another way to automate the application and web interaction, which is OLE Automation to establish traditional applications, and then automatically via the browser OLE Automation server interface. Web connection. Netscape Navigator and Microsoft Internet Explorer 3.0 The above versions support Ole Automation. Netscape Navigator's OLE Automation interface is designed for this purpose. For example, through the Ole Automation interface, let Navigator open a web page, which does not display this page in your own browser window, but download the content of the page, copy it to the server object's data buffer, let the client application Go access to these contents. For example, suppose you need Navigator to open a web page in Excel, you must first use the Excel's "Reference" dialog to reference the Navigator program directory, then use the Navigator object as an instance and complete the function of opening the page.

转载请注明原文地址:https://www.9cbs.com/read-3960.html

New Post(0)