help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html? help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
Go Back  Xtreme Visual Basic Talk > > > help using winsock to connect to a site and get html?


Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2011, 01:56 PM
pijussau pijussau is offline
Newcomer
 
Join Date: Oct 2010
Posts: 8
Default help using winsock to connect to a site and get html?


Hello, im trying to make a simple, or not that simple it occours, but maybe for you. I want to connect to lets say, hotmail.com or mail.com or whatever other site that have login. I want to login to that website and get html from that site.

I have found a coupe of scripts here and on pscode that let me connect to a website with POST, but really, i just get the returned packet which contains of server information like server:OK. It's not that i want, i want the html.

Could any help me?
Thanks.
Reply With Quote
  #2  
Old 01-24-2011, 02:09 PM
PlausiblyDamp's Avatar
PlausiblyDamphelp using winsock to connect to a site and get html? PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If you could show the code you have so far we might be able to offer some help and advice, we are not however here to write your code for you.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 01-24-2011, 04:35 PM
pijussau pijussau is offline
Newcomer
 
Join Date: Oct 2010
Posts: 8
Default

Quote:
Option Explicit

Private Sub cmdConnect_Click()
Winsock1.Close
Call Winsock1.Connect("mail.com", 80)
End Sub

Private Sub Winsock1_Connect()
'Connected, Post Form Data
Dim ExtraData As String, Pack As String
ExtraData$ = "rdirurl=http%3A%2F%2Fwww.mail.com%2Fint%2F&login=" & mail.Text & "&password=" & pass.Text & "&x=31&y=18"
Pack$ = "POST /login.html HTTP/1.1" & vbCrLf
Pack$ = Pack$ & "Host: service.mail.com" & vbCrLf
Pack$ = Pack$ & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)" & vbCrLf
Pack$ = Pack$ & "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & vbCrLf
Pack$ = Pack$ & "Accept-Language: en-us,en;q=0.5" & vbCrLf
Pack$ = Pack$ & "Accept-Encoding: gzip,deflate" & vbCrLf
Pack$ = Pack$ & "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & vbCrLf
Pack$ = Pack$ & "Keep-Alive: 300" & vbCrLf
Pack$ = Pack$ & "Connection: keep-alive" & vbCrLf
Pack$ = Pack$ & "Referer: http://www.mail.com/int/" & vbCrLf
Pack$ = Pack$ & "Cookie: cookieKID=kid%40autoref%40mail.com; ns_sample=7" & vbCrLf
Pack$ = Pack$ & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
Pack$ = Pack$ & "Content-Length: " & Len(ExtraData) & vbCrLf
Pack$ = Pack$ & "Cache-Control: no-cache" & vbCrLf & vbCrLf
Pack$ = Pack$ & ExtraData$
Call Winsock1.SendData(Pack$)
MsgBox "Sent Packet:" & vbCrLf & vbCrLf & Pack$
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Data As String
Winsock1.GetData Data
Text1.Text = Text1.Text & vbCrLf & vbCrLf & Data
Dim CurrentServer As String
Dim ReturnedHTML As String

Winsock1.GetData ReturnedHTML 'Data (HTML) returned by the server

txtData = txtData & ReturnedHTML 'Add the data to the Data Window
End Sub
This is what i have got done. The post is working good, but i don't know how to get the html of the page with Winsock1_DataArrival. Maybe use a GET command to that page? Which i btw don't know how to do.

Thanks
Reply With Quote
  #4  
Old 01-24-2011, 06:06 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default

This is the section of code you seem to misunderstand:

Code:
Dim Data As String Winsock1.GetData Data Text1.Text = Text1.Text & vbCrLf & vbCrLf & Data Dim CurrentServer As String Dim ReturnedHTML As String Winsock1.GetData ReturnedHTML 'Data (HTML) returned by the server txtData = txtData & ReturnedHTML 'Add the data to the Data Window

Data is always going to be the data. You can't just declare another variable and hope to use getdata variable to be something else.

Not sure if that makes sense... maybe this will. Get Data, Data is Data
Get NewData, Data is still Same Data.

You either need to split up your data if it needs to be, or you need to send a message to the server to get back the correct data.

Try this, can you see the html in the data of Text1.Text? With just:

Code:
Dim Data As String Winsock1.GetData Data Text1.Text = Text1.Text & vbCrLf & vbCrLf & Data

If you can, you need to parse out the html page of this data.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #5  
Old 01-25-2011, 08:45 AM
pijussau pijussau is offline
Newcomer
 
Join Date: Oct 2010
Posts: 8
Default

Can't get that to work. With Winsock1.getdata command i just get packet data, not the html.

Help?
Reply With Quote
  #6  
Old 01-25-2011, 09:33 AM
Banjo's Avatar
Banjohelp using winsock to connect to a site and get html? Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

Not sure what you mean by "packet data". The webserver will send the contents of the requested page back to you so GetData will give you the HTML.

What are you seeing and what are you expecting to see?
__________________
A wise one man once said "what you talking about dog breath"
Reply With Quote
  #7  
Old 01-25-2011, 09:33 AM
PlausiblyDamp's Avatar
PlausiblyDamphelp using winsock to connect to a site and get html? PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

So what does the actual data you get back look like?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #8  
Old 01-25-2011, 10:54 AM
pijussau pijussau is offline
Newcomer
 
Join Date: Oct 2010
Posts: 8
Default

This is what i get back:

Quote:
HTTP/1.1 302 Found
Date: Tue, 25 Jan 2011 17:52:35 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.11
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: xid=TVRnd01ETTU%3D; expires=Wed, 26-Jan-2011 17:52:35 GMT; path=/
Set-Cookie: x=3ef727acf32019fd00dda65137a55d8f; expires=Wed, 26-Jan-2011 17:52:35 GMT; path=/
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 2319
Keep-Alive: timeout=1, max=200
Connection: Keep-Alive
Content-Type: text/html

‹
This is what im expecting and hoping to get back, which im not.
Quote:
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta name="description" content="Free Email accounts and breaking News: Be informed with the latest top stories from business, sports and entertainment"/><link rel="stylesheet" type="text/css" href="http://s.mailcdn.com/1.2/css/default.css" /><!--[if IE 8]><link rel="stylesheet" type="text/css" href="http://s.mailcdn.com/1.2/css/fix-ie8.css" /><![endif]--><!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="http://s.mailcdn.com/1.2/css/fix-ie.css" /><![endif]--><!--[if IE 7]><link rel="stylesheet" type="text/css" href="http://s.mailcdn.com/1.2/css/fix-ie7.css" /><![endif]--><!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="http://s.mailcdn.com/1.2/css/fix-ie6.css" /><![endif]-->
<link rel="shortcut icon" type="image/ico" href="http://s.mailcdn.com/1.2/img/favicon.ico" /><link rel="image_src" href="http://s.mailcdn.com/1.2/img/supermailcom.png" /><script src="http://s.mailcdn.com/1.2/js/lib-head.js" type="text/javascript"></script><!--[if lte IE 6]><script src="http://s.mailcdn.com/1.2/js/iepngfix_tilebg.js" type="text/javascript"></script><![endif]-->
<title>Free Email Addresses: Web based and secure Email - mail.com</title><link title="Mail.com - the best personalized free web-based Email" type="application/rss+xml" rel="alternate" href="http://www.mail.com/rss/int/" /></head>
<body class="no-js homepagebody region-INT language-en">
<script type="text/javascript"> /* <![CDATA[ */ $ui('body').removeClass('no-js'); /* ]]> */ </script>
<div class="header" ><a href="http://www.mail.com/int/#.1258-header-logo1-undef" target="_top"><h1>Email and News Portal</h1></a><div class="search_outer"><form target="_top" action="http://search.mail.com/search/web/#.1258-header-searchfield1-undef" method="get" class="search_inner"><label class="off" for="search_top">Search</label><input type="text" title="Enter searchterm here" value="" class="search" id="search_top" name="su"><input type="hidden" name="mc" value="mailcom" /><input type="hidden" name="origin" value="hp" /><input type="image" src="http://s.mailcdn.com/1.2/img/bt_search_normal.gif" class="search-button" alt="Search with Google" /></form><script type="text/javascript">/* <![CDATA[ */ document.write ("<ul class=\"search_terms\"><li class=\"label\">Top Searches:<\/li>"); document.write ("<li><a href=\"http://search.mail.com/search/web/?origin=ticker&brand=mailcom&fq=Hot+Topics&rq=dating&su=dating#.1258-header-searchtop1-1\" target=\"_blank\">dating,<\/a><\/li>"); document.write ("<li><a href=\"http://search.mail.com/search/web/?origin=ticker&brand=mailcom&fq=Hot+Topics&rq=insurance&su=insurance#. 1258-header-searchtop1-2\" target=\"_blank\">insurance,<\/a><\/li>"); document.write ("<li><a href=\"http://search.mail.com/search/web/?origin=ticker&brand=mailcom&fq=Hot+Topics&rq=tax+rates&su=tax+rates#. 1258-header-searchtop1-3\" target=\"_blank\">tax rates,<\/a><\/li>"); document.write ("<li><a href=\"http://search.mail.com/search/web/?origin=ticker&brand=mailcom&fq=Hot+Topics&rq=online+MBA&su=online+MBA #.1258-header-searchtop1-4\" target=\"_blank\">online MBA<\/a><\/li>"); document.write ("<\/ul>"); /* ]]> */</script></div><!-- -->
<form class="countrypicker" action="http://www.mail.com/int/#.1258-header-edition1-undef" method="post" target="_top"><select id="countrypicker" name="countrypicker"><option value="/US/en" class="us">US Edition</option><option value="/INT/en" class="int" selected="selected">International Edition</option></select><input type="submit" value="Go!" /></form></div><!-- End header -->

<ul class="nav" ><li class="active"><a href="http://www.mail.com/int/#.1258-header-nav1-1" target="_top">Home</a></li><li><a href="http://www.mail.com/int/news/#.1258-header-nav1-2" target="_top"><h3>News</h3></a></li><li><a href="http://www.mail.com/int/entertainment/#.1258-header-nav1-3" target="_top"><h3>Entertainment</h3></a></li><li><a href="http://www.mail.com/int/sports/#.1258-header-nav1-4" target="_top"><h3>Sports</h3></a></li><li><a href="http://www.mail.com/int/scitech/#.1258-header-nav1-5" target="_top"><h3>Science/Technology</h3></a></li><li><a href="http://www.mail.com/int/business/#.1258-header-nav1-6" target="_top"><h3>Business</h3></a></li></ul><div class="subnav-container min"></div><!-- End subnav-container --><!-- -->
<script type="text/javascript">
/* <![CDATA[ */
ui.linkLoginHash = "#.1258-header-login1-undef";
/* ]]> */
</script>
<div class="promo-top no-slogan"><div class="promotion"><h2>Want a free email account?</h2><a href="http://service.mail.com/free-email-account-info.html#.1258-bluestripe-product1-undef">learn more</a><a href="javascript:void(0);" class="show-addresses">view all addresses</a><a class="button-medium" href="http://service.mail.com/registration.html#.1258-bluestripe-product1-undef"><span>Sign up now!</span></a></div><div class="login"><form method="post" action="http://service.mail.com/login.html#.1258-bluestripe-login1-undef" class="login-box "><p class="login-links"><a class="login-help" href="http://service.mail.com/cannotAccessMyAccount.html#.1258-bluestripe-signup1-undef">Do you need help?</a><a href="javascript:void(0)" class="ssl-switch">turn SSL&nbsp;<span>on</span></a></p><input type="hidden" name="rdirurl" value="http://www.mail.com/int/"/><label id="login-label" for="login">Email</label><input type="text" name="login" id="login" class="text" onblur="if(this.value=='')document.getElementById('login-label').style.display='block';" onfocus="document.getElementById('login-label').style.display='none';"><label class="password" id="password-label" for="password">Password</label><input type="password" id="password" class="password" name="password" onblur="if(this.value=='')document.getElementById('password-label').style.display='block';" onfocus="document.getElementById('password-label').style.display='none';"><input type="image" alt="login" class="login-submit" src="http://s.mailcdn.com/1.2/img/bt_login_normal.gif"></form><div class="login-box"><p class="login-not-possible">Please enable Java Script in your browser to log in.</p></div></div><div class="promo-addresses"><h3>Get your free Email account with one of these domain names:</h3><script type="text/javascript">/* <![CDATA[ */ui.linkListHash = "#.1258-bluestripe-signup2-undef";/* ]]> */</script><ul><li>mail.com</li><li>email.com</li><li>usa.com</li><li>consultant.com</li><li>myself.com</li><li>london.com</li></ul><ul><li>europe.com</li><li>post.com</li><li>dr.com</li><li>doctor.com</li><li>lawyer.com</li><li>engineer.com</li></ul><ul><li>techie.com</li><li>linuxmail.org</li><li>iname.com</li><li>cheerful.com</li><li>contractor.net</li><li>accountant.com</li></ul><ul><li>asia.com</li><li>writeme.com</li><li>uymail.com</li></ul><a class="close" href="javascript:void(0);">close</a></div><div class="look-like-content"></div><div class="swing-left"></div><div class="swing-right"></div></div><!-- -->

<div class="content">
<div class="main">
<h3 class="new-line">Breaking News</h3>
<div class="hero">
<div id="slide-wrapper">
<div class="items">
<div class="container-outer">
<div class="container-inner">

..................
Reply With Quote
  #9  
Old 01-25-2011, 11:55 AM
Banjo's Avatar
Banjohelp using winsock to connect to a site and get html? Banjo is offline
Hell's Angel

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Yorkshire, UK
Posts: 10,394
Default

The key is in the first line. It's the HTTP response code. In this case, 302 which is a temporary redirect. You are expected to get the new url from the location field and then download the page from there.

In your case it's a little odd since there doesn't appear to be a Location returned. Are you sure that that is the entire response from the server?
__________________
A wise one man once said "what you talking about dog breath"
Reply With Quote
  #10  
Old 01-25-2011, 11:57 AM
PlausiblyDamp's Avatar
PlausiblyDamphelp using winsock to connect to a site and get html? PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Is that the entire response? I notice the string you posted seems to cut off with what might be a unicode character - if you put the data into a byte array rather than going direct to a string does the length of data seem different?

I also notice the http response is a 302, this is normally used to indicate a redirect - I would normally expect the response to include a Location: <new location> in the response somewhere as well.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #11  
Old 01-25-2011, 12:05 PM
pijussau pijussau is offline
Newcomer
 
Join Date: Oct 2010
Posts: 8
Default

ohh, yeah that location string, sorry for that.

Quote:
HTTP/1.1 302 Found
Date: Tue, 25 Jan 2011 19:04:22 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.11
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: xid=TVRnd01ETTU%3D; expires=Wed, 26-Jan-2011 19:04:22 GMT; path=/
Set-Cookie: x=f73a221abe943c377224b4685b66a96a; expires=Wed, 26-Jan-2011 19:04:22 GMT; path=/
Location: https://my.screenname.aol.com/_cqr/l...Deq%2bzUvGU%3d
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 2319
Keep-Alive: timeout=1, max=200
Connection: Keep-Alive
Content-Type: text/html

Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html? help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html? help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
 
help using winsock to connect to a site and get html?
help using winsock to connect to a site and get html?
 
-->