ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   programmatically retrieve links from web page (https://www.excelbanter.com/excel-programming/351499-programmatically-retrieve-links-web-page.html)

Loane Sharp[_2_]

programmatically retrieve links from web page
 
Hi there

I am using the Microsoft XML v6.0 library to retrieve a web page from the
Internet, as follows:

Dim oHttp As Object
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "GET", "http://www.microsoft.com/default.aspx", False
oHttp.Send
content = oHttp.responseText

Once downloaded, I want to search through the page for all URLs that link
through to other web pages (ie. contained within <a </a tags). The problem
is that, given the huge diversity of formats for links (relative and
absolute references, url-encoding, etc.), I'm struggling to write out all
the possibilities in code.

Is there an easier way to retrieve the contents of a specific element in a
web page, or even better, to scroll through collections of elements? I've
tried XML proper (MSXML2.DOMDocument40) but this doesn't seem to work with
HTML pages' loose structure.

Best regards
Loane




Nate Oliver[_4_]

programmatically retrieve links from web page
 
Hi Loane,

Different approach, but see the following:

http://www.dicks-blog.com/archives/2...rnet-explorer/

Regards,
Nate Oliver

Loane Sharp wrote:
Once downloaded, I want to search through the page for all URLs that link
through to other web pages (ie. contained within <a </a tags). The problem
is that, given the huge diversity of formats for links (relative and
absolute references, url-encoding, etc.), I'm struggling to write out all
the possibilities in code.



Loane Sharp[_2_]

programmatically retrieve links from web page
 
Hi Nate
What a simple, elegant solution. Thanks a stack
Best regards
Loane
"Nate Oliver" wrote in message
oups.com...
Hi Loane,

Different approach, but see the following:

http://www.dicks-blog.com/archives/2...rnet-explorer/

Regards,
Nate Oliver

Loane Sharp wrote:
Once downloaded, I want to search through the page for all URLs that link
through to other web pages (ie. contained within <a </a tags). The
problem
is that, given the huge diversity of formats for links (relative and
absolute references, url-encoding, etc.), I'm struggling to write out all
the possibilities in code.






All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com