Get all URLs from a webpage

This example shows how to automate Microsoft Internet Explorer with Python/Pywin32.

It
opens a Internet Explorer window, surfs to www.goermezer.de (and waits 3
sec to load the page), and prints all links of the loaded page.

Some links to the Object Model of Microsoft Internet Explorer:

Microsoft ActiveX control

DHTML Objects 

IHTMLDocument2 Interface

import win32com.client, time
ie = win32com.client.Dispatch("InternetExplorer.Application") 
ie.Visible = 1 
ie.Navigate('http://www.goermezer.de') 
time.sleep(3) #wait 3 sec. 
print 'You are surfing on', ie.Document.domain 
print 'And now a list of the Links:' 
for i in ie.Document.links: 
    print i

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.