Skip to content

Instantly share code, notes, and snippets.

@Jack2
Created March 26, 2015 09:21
Show Gist options
  • Save Jack2/c06d5c24e4aa272748e2 to your computer and use it in GitHub Desktop.
Save Jack2/c06d5c24e4aa272748e2 to your computer and use it in GitHub Desktop.
Amecenter 1503 Downloader by Jack2
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