running on mwclient 0.8.6 (current version)

master
Castro0o 7 years ago
parent 28f7572562
commit f55323f854

@ -7,9 +7,9 @@ Install in Debian/Ubuntu: apt-get install pdftk imagemagick
Install in Mac with brew (http://brew.sh/): brew install pdftk imagemagick Install in Mac with brew (http://brew.sh/): brew install pdftk imagemagick
Python libraries: mwclient Python libraries: mwclient (version 0.8.6)
Install in Debian/Ubuntu w/ pip: sudo pip install mwclient Install in Debian/Ubuntu w/ pip: sudo pip install 'mwclient==0.8.6'
## Scripts ## Scripts

@ -38,7 +38,7 @@ def mwsite(host, path):
site = mwsite(args.host, args.path) site = mwsite(args.host, args.path)
print site #print site
@ -52,11 +52,10 @@ query= ('[[File:+]]'+ args.ask)
for answer in site.ask(query): for answer in site.ask(query):
img_key = answer.keys()[0]
print answer img_name = answer[img_key]['fulltext']
img_page_url = answer[img_key]['fullurl']
img = image.Image(site, answer) img = image.Image(site, answer)
img_name = answer.title()
img_text = img.text()
img_info = img.imageinfo # dict includes url and extensive metadata img_info = img.imageinfo # dict includes url and extensive metadata
# FILE DOWNLOAD # FILE DOWNLOAD
if 'url' in img_info.keys() and len(args.download) > 0: if 'url' in img_info.keys() and len(args.download) > 0:
@ -66,10 +65,15 @@ for answer in site.ask(query):
os.makedirs(args.download) os.makedirs(args.download)
img_data = urllib2.urlopen( img_url ) img_data = urllib2.urlopen( img_url )
img_file = open('{}/{}'.format(args.download, img_name), 'wb') img_file = open(u'{}/{}'.format(args.download, img_name), 'wb')
img_file.write(img_data.read()) img_file.write(img_data.read())
img_file.close() img_file.close()
print 'Saved to {}'.format(args.download + '/' + img_name) global download_path
if args.download[-1] != '/':
download_path = args.download+'/'
else:
download_path = args.download
print u'Saved to {}'.format(download_path + img_name)
if args.verbose: if args.verbose:
print 'File text:',img_text print 'File text:',img_text
pprint.pprint( img_info ) pprint.pprint( img_info )

Loading…
Cancel
Save