|
-
Jun 7th, 2006, 05:41 AM
#1
Thread Starter
Hyperactive Member
HTML download problem
I some code that is supposed to download a whole webpage but it seems to only download the first portion of it, maybe 50%. Why is that? Or does MsgBox only display a limited amount of characters?
VB Code:
Dim Data as String
Dim strKeywords as String
strKeywords="Dog food"
Data = Inet1.OpenURL("http://mystite.com/cgi-bin/script/script.cgi/?skin=jonclean1&length=10&keywords=" & strKeywords & "'")
MsgBox Data
Webpage html:
Code:
<span class="class1">
<p> <a href="http://www.5stardog.com/">5 Star Dog</a>
Online resource for dog owners that includes information on pet selection, training, breeders, and food along with breed descriptions, pictures, forums, and links.<br>
<a href="http://www.purina.com/intl/default.asp">Nestlé Purina PetCare Company</a>
International manufacturer and distributor of food, treats and litter for dogs and cats. Portal to specific national sites.<br>
<a href="http://www.amazon.com/exec/obidos/tg/detail/-/0439110165?v=glance">Amazon.com: Dog Food: Books: Joost Elffers,Saxton Freymann</a>
... Dog Food (Hardcover) by Joost Elffers, Saxton Freymann "Good dog ... a list of ingredients included on the back cover, Dog Food is a captivating and humorous feast for the eyes ...<br>
<a href="http://www.therustydog.com/">The Rusty Dog</a>
Carries natural foods as well as pet furniture and gifts.<br>
<a href="http://www.vegetariandogs.com/">Vegetarian Dog Food</a>
This beautiful and easy to use site is dedicated to vegetarian dog information. Find out where to purchase commercial vegetarian dog food or how you can learn to make your own. ... If you would rather purchase a commercial vegetarian dog food (see resources), you will gain confidence and the ... 90%."3 Overall, there are no major obstacles to vegetarian dog food ...<br>
<a href="http://www.vetref.net/">VetRef.net</a>
Resources for owners and veterinarians; includes articles on pet health, whole foods diets, electron microscopy, anti-roaming dog downloads, and links to other sites of veterinary interest.<br>
<a href="http://en.wikipedia.org/wiki/Dog_food">Wikipedia: Dog food</a>
Dog food is plant or animal material intended for consumption by dogs or other canids. Special dog foods given as a reward, and not as a staple, are known as dog treats. ... Some people make their own dog food or feed their dogs meals made from ingredients ...<br>
<a href="http://www.ecopet.com.au/">Ecopet</a>
Formulating natural food for dogs and cats.<br>
<a href="http://www.dogchow.com/">Purina Dog Chow</a>
Get information on nutrition for your best friend and even create a homepage for your dog.<br>
<a href="http://www.yorkie.org/supplies/pet_food.html">Rhapsody Yorkshire Terriers: Dog Food and Treats</a>
Offers treat and food recipes targeted for Yorkshire Terriers.<br>
</p>
</span>
-
Jun 7th, 2006, 07:30 AM
#2
Re: HTML download problem
Try
Debug.Print Data
then look in your immediate (debug) window... see if its all there.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 09:18 AM
#3
Thread Starter
Hyperactive Member
Re: HTML download problem
Ok, tried that and all I got was this...
Code:
<span class="class1">
<p> <a href="http://www.5stardog.com/">5 Star Dog</a>
Online resource for dog owners that includes information on pet selection, training, breeders, and food along with breed descriptions, pictures, forums, and links.<br>
<a href="http://www.purina.com/intl/default.asp">Nestlé Purina PetCare Company</a>
International manufacturer and distributor of food, treats and litter for dogs and cats. Portal to specific national sites.<br>
<a href="http://www.amazon.com/exec/obidos/tg/detail/-/0439110165?v=glance">Amazon.com: Dog Food: Books: Joost Elffers,Saxton Freymann</a>
... Dog Food (Hardcover) by Joost Elffers, Saxton Freymann "Good dog ... a list of ingredients included on the back cover, Dog Food is a captivating and humorous feast for the eyes ...<br>
<a href="http://www.therustydog.com/">The Rusty Dog</a>
Carries natural foods as well as pet furniture and gifts.<br>
<a href="http://www.vegetariandogs.com/">Vegetarian Dog Food</a>
This beautiful and easy to use site is dedicated to vegetarian dog information. Find out where to purchase commercial vegetarian dog food or how you can learn to make your own. ... If you would rather purchase a commerc
-
Jun 7th, 2006, 09:22 AM
#4
PowerPoster
Re: HTML download problem
inet and webbrowser are very similar, which is why I am posting this. When I downloaded websites with webbrowser and grab the source HTML from it, I would find that the original source would be missing certain elements that should be there. Now someone ELSE will have to help you here, but try setting HEADER data to be sent when you request the URL. Header data would include shizzle like the browser you're using, the system you're on and all-sorts like that (even cookie data if you were using a site that needed it)...without the browser information, some sites would return partial data...hope that helps :-)
Edit: In fact, I had one site that REFUSED flat out to let me send get data (form stuff) without putting valid header data in to tell it referer and all that :-)
-
Jun 7th, 2006, 10:19 AM
#5
Fanatic Member
Re: HTML download problem
Debug.Print sometimes doesn't print all data. If you want to see all the data in the string, print it to a file & then open the file manually (use 'Open "C:\debug.txt" For Output As #1...)
-
Jun 7th, 2006, 10:35 AM
#6
Thread Starter
Hyperactive Member
Re: HTML download problem
A bit later in my code it updates a mySQL database anyway so I can check. Is webbrowser better to use than inet?
-
Jun 7th, 2006, 10:37 AM
#7
Re: HTML download problem
 Originally Posted by shirazamod
Debug.Print sometimes doesn't print all data. If you want to see all the data in the string, print it to a file & then open the file manually (use 'Open "C:\debug.txt" For Output As #1...)
Debug.print doesnt print all the data??
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 10:39 AM
#8
PowerPoster
Re: HTML download problem
 Originally Posted by Jon12345
Is webbrowser better to use than inet?
The problem with webbrowser is that (unless you write in code to stop it) it loads everything on a page...images...background music (if you have it)...everything...Inet just grabs the HTML and that's it, and Inet is a hell of a lot faster in that respect because of it. However, it's a lot more work to get it working if you need specialised stuff like cookies or header info :-)
-
Jun 7th, 2006, 10:56 AM
#9
Re: HTML download problem
whats the real URL???.. using Webbrowser & HTML object you can pull any part of the page...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 11:11 AM
#10
Re: HTML download problem
VB Code:
Dim Data As String
Data = Inet1.OpenURL("http://www.vbforums.com")
While Inet1.StillExecuting = True
DoEvents
Wend
MsgBox Data
Debug.Print Data
i used vbforums as example (couldn't reach your given page). When the messagebox appears, a big part of the text is missing. if you look at debug now, it has the full code.
-
Jun 7th, 2006, 11:20 AM
#11
Thread Starter
Hyperactive Member
Re: HTML download problem
Since there seems to be a bug in the inet component, I would like to try webbrowser. So I have the following code:
VB Code:
Dim hDoc
Dim strKeywords as String
Dim HTMLSource As String
strKeywords = "dog%20food"
WebBrowser1.Navigate ("http://mysite.com/cgi-bin/script/script.cgi/?skin=jonclean1&length=10&keywords=" & strKeywords & "'")
hDoc = WebBrowser1.Document
HTMLSource = hDoc.body.innerhtml
But when I run this I get this error:
"Object variable or With block variable not set"
What is wrong with the code?
-
Jun 7th, 2006, 11:31 AM
#12
Re: HTML download problem
VB Code:
Private Sub Form_Load()
strKeywords = "dog%20food"
WebBrowser1.Navigate "http://mysite.com/cgi-bin/script/script.cgi/?skin=jonclean1&length=10&keywords=" & strKeywords & "'"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
Dim HTMLSource As String
HTMLSource = WebBrowser.Document.documentElement.innerHTML
End If
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 12:40 PM
#13
Thread Starter
Hyperactive Member
Re: HTML download problem
Static, I am a bit confused on how I would use your code. Currently, my code runs if someone clicks on a command button. It then cycles through a list of urls.
-
Jun 7th, 2006, 12:42 PM
#14
Re: HTML download problem
add the webbrowser control
then paste in the document complete code.
put the navigate to behind your button click
I cant test it because that url is no good
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 01:24 PM
#15
Thread Starter
Hyperactive Member
Re: HTML download problem
To make things simpler, I am just using www.yahoo.com
So, my code is as follows:
VB Code:
Private Sub Command1_Click()
strKeywords = "dog%20food"
WebBrowser1.Navigate "www.yahoo.com"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
Dim HTMLSource As String
HTMLSource = WebBrowser.Document.documentElement.innerHTML
End If
End Sub
When I click the button, it loads Yahoo into the WebBrowser control and then I get the error Object required. Run-time error '424'. The following line of code is then highlighted:
VB Code:
HTMLSource = WebBrowser.Document.documentElement.innerHTML
-
Jun 7th, 2006, 01:26 PM
#16
Re: HTML download problem
oops WebBrowser
WebBrowser1
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 01:34 PM
#17
Thread Starter
Hyperactive Member
Re: HTML download problem
No error message now. But I can't see how the WebBrowser1_DocumentComplete subroutine is called. From what I can see, you click the button and it just runs the two lines of code.
What am I missing here?
-
Jun 7th, 2006, 01:40 PM
#18
Fanatic Member
Re: HTML download problem
When the website has been fully loaded (including images etc) it will call the DocumentComplete event
-
Jun 7th, 2006, 01:42 PM
#19
Re: HTML download problem
you are also not displaying it anywhere 
add
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 02:58 PM
#20
Thread Starter
Hyperactive Member
Re: HTML download problem
What I am getting confused about is that I want to run a loop with changing urls. This will happen when I click the command button. But it seems that "Private Sub Command1_Click()" subroutine loses control and another subroutine is triggered.
Therefore, I cannot loop through the code for changing urls, correct?
-
Jun 7th, 2006, 03:09 PM
#21
Re: HTML download problem
Yes.. I would do it like this
(assuming u have URLs listed in Listbox (List1))
VB Code:
Dim lIndex As Integer
Private Sub Command1_Click()
lIndex = 0
LoopURLS
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
Debug.Print WebBrowser.Document.documentElement.innerHTML
LoopURLS
End If
End Sub
Private Sub LoopURLS()
Dim tmp As String
If lIndex >= List1.ListCount Then Exit Sub
tmp = List1.List(lIndex)
WebBrowser1.Navigate tmp
lIndex = lIndex + 1
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 7th, 2006, 04:31 PM
#22
Thread Starter
Hyperactive Member
Re: HTML download problem
Thanks Static! I will give that a whirl.
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
|