Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Getting data from a webpage

Okay, I'm needing to do this same thing again, but can't figure out where the
item/innertext I need is:
The webpage is:
http://www.gocomics.com/calvinandhobbes/2010/01/16

....and what I need is the image (on this particular page it's):
http://imgsrv.gocomics.com/dim/?fh=8...8010a8&w=900.0

thanks, SouthernAtHeart


"Joel" wrote:

You don't need to get the source. You can use the IE explorer like below to
help you filter the data. The source is under the IE.Document.all property.
You can get these lines by doing a loop like this

for each itm in IE.Document
'your code here
next itm

You can use the methods getElementsByTagname(), and getElementById() to help
you filter the data. I often for debuggin use something like this

RowCount = 1
for each itm in IE.Document
Range("A" & RowCount) = itm.tagname
Range("B" & RowCount) = itm.Classname
Range("C" & RowCount) = itm.id
Range("D" & RowCount) = left(itm.innertext,1024)

RowCount = rowcount + 1
next itm

The source is partioned into items. Has you go down the ALL property the
innertext is partioned into small pices. When you do the dump above you will
see the same innertext repeated over and over again but broken into samller
pieces each time it is repeated.

If you need more help give me the URL and I will get what you need. I help
lots of people who have had problems.

  #2   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default Getting data from a webpage

On Jan 18, 12:14*pm, Southern at Heart
wrote:
Okay, I'm needing to do this same thing again, but can't figure out where the
item/innertext I need is:
The webpage is:http://www.gocomics.com/calvinandhobbes/2010/01/16

...and what I need is the image (on this particular page it's):http://imgsrv.gocomics.com/dim/?fh=8...078a548010a8&w...

thanks, SouthernAtHeart


The following should do want you want. It will paste the image to the
activesheet, but once it is in the clipboard you can do whatever you
want with it...Ron

Sub Comics()
' Open the first webpage
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
.navigate "http://www.gocomics.com/calvinandhobbes/2010/01/16
"
.Top = 50
.Left = 530
.Height = 400
.Width = 400

' Loop until the page is fully loaded
Do Until .ReadyState = 4 And Not .Busy
DoEvents
Loop

' Determine the url for the image
my_var = ie.document.body.innerhtml
loc_1 = InStr(1, my_var, "feature_item", vbTextCompare)
loc_2 = InStr(loc_1, my_var, "//", vbTextCompare)
loc_3 = InStr(3 + loc_2, my_var, "", vbTextCompare)
my_url = Trim(Mid(my_var, 2 + loc_2, loc_3 - (2 + loc_2)))

' Go to the image url and copy the image and paste to the activesheet
ie.navigate my_url

Do Until ie.ReadyState = 4 And Not ie.Busy
DoEvents
Loop

ie.ExecWB 17, 2
ie.ExecWB 12, 0
ActiveSheet.PasteSpecial

End With

ie.Quit
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Getting data from a webpage

Thanks.
Works great!
What would I need to change to make this work in Word 2003?
Seems like it all works accept the activesheet.pastespecial.
I thought it might be activedocument.pastespecial, but it must not be...
thanks again.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default One step further

How can I end this code so that it will save the image in 'My Documents'
instead of pasting it into the word document? It is a .gif format on the
web, but it can be something else if it's easier.
Thanks.

"ron" wrote:

On Jan 18, 12:14 pm, Southern at Heart
wrote:
Okay, I'm needing to do this same thing again, but can't figure out where the
item/innertext I need is:
The webpage is:http://www.gocomics.com/calvinandhobbes/2010/01/16

...and what I need is the image (on this particular page it's):http://imgsrv.gocomics.com/dim/?fh=8...078a548010a8&w...

thanks, SouthernAtHeart


The following should do want you want. It will paste the image to the
activesheet, but once it is in the clipboard you can do whatever you
want with it...Ron

Sub Comics()
' Open the first webpage
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
.navigate "http://www.gocomics.com/calvinandhobbes/2010/01/16
"
.Top = 50
.Left = 530
.Height = 400
.Width = 400

' Loop until the page is fully loaded
Do Until .ReadyState = 4 And Not .Busy
DoEvents
Loop

' Determine the url for the image
my_var = ie.document.body.innerhtml
loc_1 = InStr(1, my_var, "feature_item", vbTextCompare)
loc_2 = InStr(loc_1, my_var, "//", vbTextCompare)
loc_3 = InStr(3 + loc_2, my_var, "", vbTextCompare)
my_url = Trim(Mid(my_var, 2 + loc_2, loc_3 - (2 + loc_2)))

' Go to the image url and copy the image and paste to the activesheet
ie.navigate my_url

Do Until ie.ReadyState = 4 And Not ie.Busy
DoEvents
Loop

ie.ExecWB 17, 2
ie.ExecWB 12, 0
ActiveSheet.PasteSpecial

End With

ie.Quit
End Sub
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving data to a webpage steve New Users to Excel 2 February 24th 08 09:00 PM
getting data from website's url and webpage [email protected] Excel Programming 1 February 10th 08 10:12 PM
Importing webpage data into Excel Dave Excel Discussion (Misc queries) 4 May 21st 07 09:04 PM
Get Webpage data as text using VBA w/o Webquery Max Excel Programming 0 March 15th 07 06:40 AM
data from external webpage R.VENKATARAMAN Excel Programming 2 August 23rd 05 06:56 AM


All times are GMT +1. The time now is 07:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"