Comment lire la source d'une page web ?

Clem - 7 mai 2001 à 14:34
cs_rootdaoud Messages postés 2 Date d'inscription vendredi 31 octobre 2003 Statut Membre Dernière intervention 4 février 2005 - 4 févr. 2005 à 18:52
Comment lire la source d'une page web comme www.vbfrance.com ?

6 réponses

menu Affichages bouton source

A+

Schouly
0
Je veux dire télécharger en vb la source d'un site web.
Je pense que c'est avec WinSock ou Inet mais je n'arrive pas a les utiliser.
0
-------------------------------
Réponse au message :
-------------------------------

Comment lire la source d'une page web comme www.vbfrance.com ?
0
Aaaahhh !!!!!!!!!!!!!! il me semblait bien que la question n'était ni en rapport avec Vb ni très difficile à répondre...

Source : www.allapi.net

The Professional and Enterprise Editions of Visual Basic are shipped with the Winsock control. This control allows you to use the low level Windows Sockets to connect to remote servers and execute commands or download Web pages. This tip shows how to connect to a server and download a Web page.

Code

You must have a Winsock control loaded into the project. This code assumes the control is called Winsock1. There also must be a text box on the form which is called txtWebPage.

First, connect to the remote computer using the following code:

Winsock1.RemoteHost = "microsoft.com"
Winsock1.RemotePort = 80
Winsock1.Connect

In the Winsock1.Connect event, place the following code to download the web page.

Dim strCommand as String
Dim strWebPage as String
strWebPage = "http://www.microsoft.com/index.phpl"
strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
strCommand = strCommand + "Accept: */*" + vbCrLf
strCommand = strCommand + "Accept: text/html" + vbCrLf
strCommand = strCommand + vbCrLf
Winsock1.SendData strCommand

The Winsock control will attempt to download the page. When is receives some data from the server, it will trigger the DataArrival event.

Dim webData As String
Winsock1.GetData webData, vbString
TxtWebPage.Text = TxtWebPage.Text + webData
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
c'est asser simple!
Sur une feuille tu mets:
un TextBox
un Inet
un autre TextBox (avec l'option Multiligne, donc le faire asser grand)
un Boutton

et voilà la source.

Dim Url as string

Private Sub Command1_click()
Url = Text1.text
Text2.text = Inet1.OpenURL(Url)
End Sub

Et voilà c tt :)
Le Text1 sert à mettre l'url complet genre "http://www.VbFrance.com/Source.html", il faut un fichier avec une extension.

@+
0
cs_rootdaoud Messages postés 2 Date d'inscription vendredi 31 octobre 2003 Statut Membre Dernière intervention 4 février 2005
4 févr. 2005 à 18:52
voilà le code que vous permet de faire ça:
s'il ya une question : [mailto:rootdaoud@yahoo.fr rootdaoud@yahoo.fr]

Private WithEvents IE As InternetExplorer
Set IE = New InternetExplorer
IE.navigate "[/ www.vbfrance.com]"
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)


Dim ch as String
Dim Doc As IHTMLDocument2
Set Doc = IE.document
ch =Doc.body.innerhtml

ENB: n'oubliez pas de faire la refference a microsoft html object library(projet/references)
nd Sub.
0
Rejoignez-nous