Jump to content
Heads Up! This website is no longer maintained, if your a member from our era, consider joining the discord to say hello.
Sign in to follow this  

Connect to Google and return HTML

Recommended Posts

Start a new project, make a Winsock component names "Sck", a button named "cmdConnect", and a button named "cmdDisconnect".

 

All of the HTML sent back will show up in the immediate window.

Private Sub cmdConnect_Click()
Sck.Close
Sck.Connect "www.google.com", 80
End Sub

Private Sub cmdDisconnect_Click()
Sck.Close
End Sub



Private Sub Sck_Close()
Debug.Print "Closed"
End Sub

Private Sub Sck_Connect()
Debug.Print "Connected"
Sck.SendData (SendHeaders)
Debug.Print "sending headers"
End Sub

Private Sub Sck_DataArrival(ByVal bytesTotal As Long)
Debug.Print "Data Arrival"
Sck.GetData SckData, vbString

Debug.Print SckData
End Sub

Function SendHeaders()

SendHeaders = SendHeaders & "GET / HTTP/1.1" & vbCrLf
SendHeaders = SendHeaders & "Host: www.google.com" & vbCrLf
SendHeaders = SendHeaders & "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7" & vbCrLf
SendHeaders = SendHeaders & "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & vbCrLf
SendHeaders = SendHeaders & "Accept-Language: en-us,en;q=0.5" & vbCrLf
SendHeaders = SendHeaders & "Accept -Encoding: gzip , deflate" & vbCrLf
SendHeaders = SendHeaders & "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & vbCrLf
SendHeaders = SendHeaders & "Keep-Alive: 300" & vbCrLf
SendHeaders = SendHeaders & "Connection: keep -alive" & vbCrLf
SendHeaders = SendHeaders & "Cache -Control: Max -age = 0" & vbCrLf & vbCrLf


End Function

Private Sub Sck_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Debug.Print Description
End Sub

Share this post


Link to post

ANice introduction into winsock, easier to use a HTTPWrapper control though.

Share this post


Link to post

lol ur gona be telling everybody how to use VB?

Share this post


Link to post

Well, why not, he's helped me with VB stuff before, I'd recommend him for it.

Share this post


Link to post

ok its just kinda weird every 3rd topic is about vb

Share this post


Link to post

rockage, winsock lets you send more specific packets, like if you wanted to change cookies and stuff, like for the stickam adder, i had to change cookies and referers alot, and i also had to read them. HTTPWrapper is good if you just want to grab a single page for something.

 

Union1, I'm just sharing my knowledge that i know people would use later, or even that i use alot. Alot of the stuff im posting is used alot when you get into VB6.

Share this post


Link to post

With HTTPWrapper you can change referrers and cookies as well :o

Share this post


Link to post

Yeah, but winsck just pwns.

-.-

Share this post


Link to post

Could you write a login for gmail for me ? Function is fine but it can just be in a command sub.

 

txtUser.text = username

txtPass.text = password

 

I'm not familiar with winsock and cannot access https sites (ex. gmail) with httpwrapper.

Share this post


Link to post

wow that was japanese to me :D

but i actully kinda sorta wanna learn it :)

what programs do i need?? and what it do?

Share this post


Link to post

to bad .net doesnt use that component anymore...

Share this post


Link to post

Rockage - Logins take too long and i think google uses handshakes that i dont have time to figure out.

 

MadMatt - Download Visual Basic 6 (Hint, it's not free ;])

Share this post


Link to post

w 0 0 t? isnt vb6 free? i got it for free :D

Share this post


Link to post

It's free if you make it free.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×