I'm trying to retrieve the source of a webpage, including any images. At the moment I have this:
import urllib
page = urllib.urlretrieve('http://127.0.0.1/myurl.php', 'urlgot.php')
print urlgot.php
which retrieves the source fine, but I also need to download any linked images.
I was thinking I could create a regular expression which searched for img src or similar in the downloaded source; however, I was wondering if there was urllib function that would retrieve the images as well? Similar to the wget command of:
wget -r --no-parent http://127.0.0.1/myurl.php
I don't want to use the os module and run the wget, as I want the script to run on all systems. For this reason I can't use any third party modules either.
Any help is much appreciated! Thanks