Go Back   DeveloperBarn Forums > Operating Systems, Servers & Software > Microsoft Office

Sponsored Links

Discuss "Retrieving Web Data using Excel" in the Microsoft Office forum.

Microsoft Office - Learn helpful tips and tricks to get the best out of Office suite, using Excel, Word, PowerPoint and more. Discuss how to automate repetitive tasks and more.


Reply « Previous Thread | Next Thread »
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1  
Old March 25th, 2008, 09:52 AM
mehere's Avatar
Super Sarcasm Mistress


 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 143
Thanks: 10
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Question Retrieving Web Data using Excel

I have an excel program that will retrieve data from websites and place it into an excel spreadhseet ... however, it only works with table data. The sites I need to retrieve the data from are using DIV tags and i'm finding it hard to just grab that info.

The excel module uses the following:
Code:
Sub ImportDataWeb()
    
    Sheets("Website Data").Activate
    i = 1
    Do Until Sheets("Hyperlinks Here").Cells(i, 2) = ""
        myquery = Sheets("Hyperlinks Here").Cells(i, 2)
        Sheets("Website Data").Cells(1, 1) = myquery
        myrow = Sheets("Website Data").UsedRange.Rows.Count + 1
        Do
            myrow = myrow - 1
        Loop Until Sheets("Website Data").Cells(myrow, 1) <> ""
        myrow = myrow + 3
        With Sheets(3).QueryTables.Add(Connection:= _
            "URL;" & myquery, Destination:=Sheets(3).Cells(myrow, 1))
            .BackgroundQuery = True
            .TablesOnlyFromHTML = True
            .Refresh BackgroundQuery:=False
            .SaveData = True
        End With
        i = i + 1
    Loop
    
End Sub
with the code TablesOnlyFromHTML, it will grab the data in the table and place it where I need it. However, if I use False, it grabs all the data on the page and with that, it's hard to get just what I need.

Anyone have any ideas?
__________________
Quote of the Month:
Regret: It hurts to admit when you make mistakes - but when they're big enough, the pain only lasts a second.

Questions to Ponder:
Could it be that all those trick-or-treaters wearing sheets aren’t going as ghosts but as mattresses?

iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
copyright © 2008 sbenj69
Reply With Quote
Sponsored Links
  #2  
Old March 25th, 2008, 10:10 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 817
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

I'm not sure what you're asking can be done very easily. It seems you would have to create a function to actually parse through the HTML and retrieve the information you want. If they had an XML file that was available which contains this data, that would be another story. That would be quite simple.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old March 25th, 2008, 10:35 AM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 395
Thanks: 26
Thanked 32 Times in 32 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

Does the webpage just contain data or is there lots of other HTML info?

Could you give an example of how the page is displayed and/or how the data is formatted?
Reply With Quote
  #4  
Old March 25th, 2008, 10:39 AM
mehere's Avatar
Super Sarcasm Mistress


 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 143
Thanks: 10
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

here's a url of an example page i need to get the data from. i would have to gather the name, address, phone & ins co name(s) from this page. this data then needs to go into something like a .CSV file for later import into a SQL Table.

click here. this is not the page i need to scrub, just and example of what i'm looking to do.
Reply With Quote
  #5  
Old March 25th, 2008, 10:42 AM
richyrich's Avatar
Moderator


 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 395
Thanks: 26
Thanked 32 Times in 32 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

And you want the details of the "Local Agents" down the left hand side?
Reply With Quote
  #6  
Old March 25th, 2008, 10:45 AM
mehere's Avatar
Super Sarcasm Mistress


 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 143
Thanks: 10
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

yes ... for example
name: Joseph Kaplan
address: 617 New York Ave, Absecon, NJ 08201
phone: (609) 645-8543
ins co: High Point
etc....
Reply With Quote
  #7  
Old March 25th, 2008, 02:12 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 817
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

mehere, perhaps this is what you're looking for:

Code:
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "http://www.yahoo.com" 'Place site URL here
IE.Visible = False 'Does not display the browser window
 
While IE.Busy
    DoEvents
Wend
 
x = IE.document.body.innerHTML
IE.Quit
In the above code, html in the body tag will be stored in the variable 'x'. If each div has an ID, I would imagine you could somehow access it this way.
Reply With Quote
  #8  
Old March 25th, 2008, 02:16 PM
mehere's Avatar
Super Sarcasm Mistress


 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 143
Thanks: 10
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

will look into that ... is this VBA or what?
Reply With Quote
  #9  
Old March 25th, 2008, 02:17 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 817
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by mehere View Post
will look into that ... is this VBA or what?
Yes.
Reply With Quote
  #10  
Old March 25th, 2008, 02:45 PM
mehere's Avatar
Super Sarcasm Mistress


 
Join Date: Mar 2008
Location: Wide Awake In Dreamland
Posts: 143
Thanks: 10
Thanked 27 Times in 25 Posts
Rep Power: 1
mehere will become famous soon enough

Awards Showcase
Microsoft SQL Server Classic ASP 
Total Awards: 2

Default

yes it's VBA? or yes it's what? ...
Reply With Quote
Reply

  DeveloperBarn Forums > Operating Systems, Servers & Software > Microsoft Office

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/microsoft-office/68-retrieving-web-data-using-excel.html
Posted By For Type Date
DeveloperBarn Forums - ASP Help, ASP.Net Help, PHP Help, SQL Help, Tutorials, Windows Help This thread Refback April 26th, 2008 09:37 AM


All times are GMT -4. The time now is 12:38 PM.



Content Relevant URLs by vBSEO 3.2.0