Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 224
Default Get data from web site - hyperlinks in divs in html table

I need to download data from a web site. I'm familiar with how to use
an InternetExplorer object to navigate to the page etc. But how do I
get this data:


The web page source for the table of data I want looks like this:


<table border="0" cellpadding="15" cellspacing="0" width="580"
<tr
<td class="copy"
<div class="mahead"<bItem 1</b -- <a href="http://
www.website.com/webpage.html"view page</a</div
<div class="mahead"<bOther Thing</b -- <a href="http://
www.website.com/someotherpage.html"view page</a</div
<div class="mahead"<bNew Stuff</b -- <a href="http://
www.website.com/yetanotherpage.html"view page</a</div
<br /<br /<br /<br /<br /
</td
</tr
</table


Where my example shows only three items, the real web page has many
more, each as a <div, all in the same <td.

What I need to get is:

[Field 1] [Field 2]
Item1 http://www.website.com/webpage.html
Other Thing http://www.website.com/someotherpage.html
New Stuff http://www.website.com/yetanotherpage.html


How do I get that data?



BTW, if I use Excel's Get External Data From Web feature, I get this
table:

[Field 1] [Field 2]
Item1 view page
Other Thing view page
New Stuff view page

With no sign of the urls, which I need.



Thanks for any suggestions.

Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Get data from web site - hyperlinks in divs in html table

Greg

This will get all the links from that particular HTML code.

Private Sub GetAllLinks()
Dim IE As Object
Dim doc As Object
Dim lnks As Object
Dim l
Dim pos
Dim rng As Range

Set rng = Range("A1")
Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True

IE.Navigate "C:\GetLinksFromDivsTest.html"

Do While IE.Busy: DoEvents: Loop
Do While IE.ReadyState < 4: DoEvents: Loop

Set doc = IE.Document

Set lnks = doc.getelementsbytagname("A")

For Each l In lnks

rng = l.innertext
rng.Offset(, 1) = l

Set rng = rng.Offset(1)
Next l

IE.Quit: Set IE = Nothing

End Sub

Similar code could be used to get all the tables, all the divs etc




On Jun 22, 8:30*am, Greg Lovern wrote:
I need to download data from a web site. I'm familiar with how to use
an InternetExplorer object to navigate to the page etc. But how do I
get this data:

The web page source for the table of data I want looks like this:

<table border="0" cellpadding="15" cellspacing="0" width="580"
* * * * <tr
* * * * * * * * <td class="copy"
* * * * * * * * * * * * <div class="mahead"<bItem 1</b -- <a href="http://www.website.com/webpage.html"view page</a</div
* * * * * * * * * * * * <div class="mahead"<bOther Thing</b -- <a href="http://www.website.com/someotherpage.html"view page</a</div
* * * * * * * * * * * * <div class="mahead"<bNew Stuff</b -- <a href="http://www.website.com/yetanotherpage.html"view page</a</div
* * * * * * * * * * * * <br /<br /<br /<br /<br /
* * * * * * * * </td
* * * * </tr
</table

Where my example shows only three items, the real web page has many
more, each as a <div, all in the same <td.

What I need to get is:

[Field 1] * * * * * [Field 2]
Item1 * * * * * * *http://www.website.com/webpage.html
Other Thing * * *http://www.website.com/someotherpage.html
New Stuff * * * *http://www.website.com/yetanotherpage.html

How do I get that data?

BTW, if I use Excel's Get External Data From Web feature, I get this
table:

[Field 1] * * * * * [Field 2]
Item1 * * * * * * * view page
Other Thing * * *view page
New Stuff * * * * view page

With no sign of the urls, which I need.

Thanks for any suggestions.

Greg


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
Creating customized hyperlinks to a site Natarajan Excel Discussion (Misc queries) 5 December 12th 07 01:20 AM
Copy a table from a web site, then manipulate the data? Confused Rookie Excel Worksheet Functions 1 October 24th 06 12:19 AM
How can I cut data out of HTML table, into msExcel and just take the data & columns? (but NOT the formatting & URLs!) ship Excel Discussion (Misc queries) 24 April 25th 06 06:02 PM
Import External Data Non-HTML Table Jay637 Excel Discussion (Misc queries) 0 March 9th 06 04:37 PM
Getting Table data from HTML page Mustafa Ahmad Malik Excel Programming 12 April 16th 04 02:11 PM


All times are GMT +1. The time now is 08:29 PM.

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

About Us

"It's about Microsoft Excel"