Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
downloads picasa web album to current dir
Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
from lxml import etree | ||
from lxml.html import parse, tostring, fromstring | ||
import urllib.request | ||
import sys | ||
|
||
|
||
if len(sys.argv) == 2: | ||
url = sys.argv[1] | ||
url = url + "&imgdl=1" | ||
|
||
parser = etree.XMLParser(ns_clean=True, recover=True) | ||
try: | ||
xml = etree.parse(url,parser) | ||
items = xml.findall('//item') | ||
|
||
# iterate over items | ||
for item in items: | ||
title = item.xpath('title')[0].text | ||
photo = item.xpath("m:group/m:content/@url",namespaces={"m": "http://search.yahoo.com/mrss/"}) | ||
photo = photo[0] | ||
f = urllib.request.urlopen(photo) | ||
locale_file = open(title,"wb") | ||
locale_file.write(f.read()) | ||
locale_file.close() | ||
except IOError: | ||
print ("Couldn't parse source {0} ".format(url)) | ||
else: | ||
print ("Provide more url, note that https doesn't work atm") |