import sys, urllib.request, urllib.parse, urllib.error, re, urllib.parse
from BeautifulSoup import BeautifulSoup
if not len(sys.argv) == 2:
    print('Usage: %s <URL>' % (sys.argv[0],), file=sys.stderr)
sys.exit(1)
url = sys.argv[1]
f = urllib.request.urlopen(url)
soup = BeautifulSoup(f)
for i in soup.findAll('img', attrs={'src': re.compile('(?i)(jpg|png)$')}):
    full_url = urllib.parse.urljoin(url, i['src'])
print('image URL: ', full_url)
Python download all files from internet address?