Topic: "help needed on using the Winsock control to access the internet." (page 1 of 1)

1
Author Post
aceldama
groupmastergroupmastergroupmastergroupmaster
Hi all.

i was jus hacking away at my PC today, trying as i might to create a VB program that should access a web page and retrieve the sourcecode. but try as i might, all my attempts seemed to be futile. i could connect to the site (say www.bright-shadows.net) but attempting to send my headers (after googling and googling and programming for ages then googling again - ad nausium) yielded... ...absolutely nothing.:rage: would anyome please be so kind as to just point me in the right direction on what to put in the header and how to send it (if it is indeed possible using VB ) any help would be greatly appreciated.:nick:
private message
unknown user
you should really have been able to figure this out yourself however

if i recall correctly:

Drag a winsock control to the form
winsock.close
winsock.connect "bright-shadows.net",80
do:doevents:loop until winsock.state=7

$r="GET / HTTP/1.0"+vbcrlf
$r=$r+"Host: www.bright-shadows.net"+vbcrlf+vbcrlf
winsock.send($r);
do:doevent:loop until winsock.state=8

or something similar

use winsock.getdata to retrieve the data. you might want to buffer it in the datareceived event.
EMail
unime
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
You might find a network analysis program such as ethereal helpful. You can see what programs send and recieve over the net, allowing you to check what your code actually does and compare that with, for example, your browser's comunications.

I avoid windows so I can't help you with VB programming. As a general rule when writing low level network code, I look for a sample program to use as a guide.
private message EMail
unstable
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
You failed to mention which version of VB you use, specifically VB or VB.NET. Assuming you use VB, you could use a regular WebBrowser control, and get the source of the page using WebBrowser.innerHTML. WebBrowser controls also have an innerText property, which returns the text in a webpage without the HTML tags.
A much cleaner solution would of course be to use the Internet Transfer control, but sometimes VB doesn't seem to permit clean solutions. The reason for this is because the Internet Transfer control doesn't allow you to set headers, so you can't set the cookie. You could work around this by using proxomitron, and manually adding the cookie as an outgoing header. Of course this also means you have to use localhost:8080 as a proxy server in your application, but if I remember correctly, if you go to the Internet Options (you can get there through the configuration manager, or by going to the options in IE) and change the proxy server there, your program will then also use this proxy server.

Regards,

unstable
private message EMail
aceldama
groupmastergroupmastergroupmastergroupmaster
currently using VB6 (don't laugh :hihi::pc2:) anyway, thanks for letting me know about the innerHTML function. i shall try that. thank you all for the help. i shall now retire - i'm rather tired after a 16 hour night-shift...
private message

Topic: "help needed on using the Winsock control to access the internet." (page 1 of 1)

1