Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79101 > unrolled thread
| Started by | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| First post | 2014-10-14 14:42 +0000 |
| Last post | 2014-10-14 08:31 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
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
| From | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| Date | 2014-10-14 14:42 +0000 |
| Subject | downloading from links within a webpage |
| Message-ID | <mailman.14853.1413297763.18130.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Rustom Mody <rustompmody@gmail.com> |
|---|---|
| Date | 2014-10-14 08:31 -0700 |
| Message-ID | <6ad706a4-7c9c-43e0-b9d9-0eedc3cec30f@googlegroups.com> |
| In reply to | #79101 |
On Tuesday, October 14, 2014 8:12:56 PM UTC+5:30, Shiva wrote: > 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 Read this: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web