|
-
Jun 4th, 2006, 12:29 AM
#1
Thread Starter
New Member
Capturing data from a website
OK, this is the age-old question. Does anyone know how (or can refer me to any source of information) I can use VB6 to extract data from a website to use in a VB6 application? I will use the usual example of extracting stock and share prices from a "live" site, such as the Australian Stock Exchange (which, coincidentally, is exactly what I am trying to do). As an example, say I was creating an application for my desktop that accessed the internet to extract the live share prices from the remote website to display them in my application. Anyway, any advice and/or assistance would be gratefully received.
Schmalz
-
Jun 4th, 2006, 12:41 AM
#2
Re: Capturing data from a website
Welcome to the Forums.
Check out my code examples in this thread - http://www.vbforums.com/showthread.php?t=330341
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 12:41 AM
#3
Fanatic Member
Re: Capturing data from a website
Welcome to the forum Schmalz!
You could use the Inet control if you want a simple way to get the html source from a website.
The Inet control is called the 'Internet Transfer Control' and once you've added it to your form all you need to do to get the html for a site is use
VB Code:
Dim HTML as String
HTML = Inet1.OpenURL("http://www.google.com")
-
Jun 4th, 2006, 12:44 AM
#4
Re: Capturing data from a website
The only thing with the Inet control is that the site in question probably has security in place to prohibit this type of interaction. so by using a web browser control and parse it out you will get much further easier.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 01:11 AM
#5
Fanatic Member
Re: Capturing data from a website
@RobDog888, what kind of security prevents the Inet's connection?
As far as I know it acts exactly as a webbrowser except its stripped down
-
Jun 4th, 2006, 01:12 AM
#6
Re: Capturing data from a website
Like if your trying to automate a search query on google, it prevents automation somehow.
They dont want you using their search engine behind the scenes without credit given to googlem,etc
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 01:26 AM
#7
Fanatic Member
Re: Capturing data from a website
WOW, I've never encountered that before!
All the websites that I've used the Inet for have worked fine.
I'm going to investigate how they worked out I wasn't using regular IE.
-
Jun 4th, 2006, 01:34 AM
#8
Re: Capturing data from a website
They have some major security in place to prevent attacks, automation, and hacking. If you think about it, they would be really foolish if they didnt because then we all could take advantage of their services for free or without acknolowging them.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 01:38 AM
#9
Fanatic Member
Re: Capturing data from a website
Ok, I did some tests on my webserver and I think the way they validate you is by the User-Agent header, so if you spoof it you will be able to get unrestricted access
-
Jun 4th, 2006, 01:40 AM
#10
Re: Capturing data from a website
such an easy workaround. Did it work on google?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 01:49 AM
#11
Fanatic Member
Re: Capturing data from a website
Just finished working on it.
I managed to fool Google!
Only problem is that I don't know how to change the headers when using .OpenURL so I had to use .Execute instead.
VB Code:
Inet1.Execute "http://www.google.com/search?q=fly", "GET", , "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
If you know how to edit headers while using .OpenURL please let me know
-
Jun 4th, 2006, 04:14 AM
#12
Re: Capturing data from a website
If you use the InternetOpen API it has an argument for the Agent.
VB Code:
hOpen = InternetOpen("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hConnection = InternetConnect(hOpen, "google.com", INTERNET_DEFAULT_HTTP_PORT, vbNullString, vbNullString, INTERNET_SERVICE_HTTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
'...
'...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jun 4th, 2006, 04:58 AM
#13
PowerPoster
Re: Capturing data from a website
and in MSXML
VB Code:
Dim objHTTP As New MSXML.XMLHTTPRequest
Dim strData As String
objHTTP.Open "get", "http://www.google.com/search?q=fly", False
objHTTP.setRequestHeader "Content-Type", "text/html"
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
objHTTP.send
strData = objHTTP.responseText
and winsock ..
VB Code:
Dim strData As String
strData = "GET [url]http://www.google.com/search?q=fly[/url] HTTP/1.0" & vbNewLine
strData = strData & "Host: www.google.com" & vbNewLine
strData = strData & "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
strData = strData & vbNewLine & vbNewLine
Winsock1.SendData strData
Last edited by rory; Jun 4th, 2006 at 05:01 AM.
-
Jun 8th, 2006, 09:23 AM
#14
Thread Starter
New Member
Re: Capturing data from a website
Thanks for your help so far guys (and gals?). I am still trying to come to grips with this Inet thing. Can you confirm if it works with "live" data such as a website created "on the fly" by php etc.? Also, how can I, say, access a site and fill in a form using a VB6 application?
-
Jun 8th, 2006, 09:28 AM
#15
PowerPoster
Re: Capturing data from a website
see post 11 .. send the querystring as well ... wont 'fill in a form' but you can send it to the page that processes the form .. i dont know php but dont use .form use .querystring and get for the form instead ..
http://www.myurl.com/default.php?myvar=this
-
Jun 8th, 2006, 09:31 AM
#16
Fanatic Member
Re: Capturing data from a website
Try www.planet-source-code.!!!!!!!
Dont rely only on your luck. Work hard until You get success.
vb Code:
Private sub Time_ispassing
While Me.Notgetsuccess
trygain=tryagain+1
Me.workhard
wend
end sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|