Created
March 26, 2015 09:21
-
-
Save Jack2/c06d5c24e4aa272748e2 to your computer and use it in GitHub Desktop.
Amecenter 1503 Downloader by Jack2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
from bs4 import BeautifulSoup | |
## Print all JPGs from a Site | |
def down_from_site(type,url): | |
soup = BeautifulSoup(urllib.urlopen(url)) | |
#EDIT - <a> tag + <class> name tag | |
links=soup.findAll('a') | |
#print links | |
x=[] | |
try: | |
for u in links: | |
type_url = u.get('href') | |
if type_url is not None and type_url.strip().endswith(type): | |
l = 'http://www.suname.org/data/cheditor4/1503/'+type_url.encode('ascii','ignore') | |
#print l | |
#print l.split('/')[-1:][0].replace(':',' -') | |
urllib.urlretrieve(l,l.split('/')[-1:][0].replace(':',' -')) | |
except Exception, e: | |
print e | |
#EDIT | |
url= 'http://www.suname.org/data/cheditor4/1503/' | |
down_from_site('jpg',url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment