Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79101
| From | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| Subject | downloading from links within a webpage |
| Date | 2014-10-14 14:42 +0000 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14853.1413297763.18130.python-list@python.org> (permalink) |
Hi,
Here is a small code that I wrote that downloads images from a webpage url
specified (you can limit to how many downloads you want). However, I am
looking at adding functionality and searching external links from this page
and downloading the same number of images from that page as well.(And
limiting the depth it can go to)
Any ideas? (I am using Python 3.4 & I am a beginner)
import urllib.request
import re
url="http://www.abc.com"
pagehtml = urllib.request.urlopen(url)
myfile = pagehtml.read()
matches=re.findall(r'http://\S+jpg|jpeg',str(myfile))
for urltodownload in matches[0:50]:
imagename=urltodownload[-12:]
urllib.request.urlretrieve(urltodownload,imagename)
print('Done!')
Thanks,
Shiva
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
downloading from links within a webpage Shiva <shivaji_tn@yahoo.com> - 2014-10-14 14:42 +0000 Re: downloading from links within a webpage Rustom Mody <rustompmody@gmail.com> - 2014-10-14 08:31 -0700
csiph-web