import urllib, base64 from bs4 import BeautifulSoup
def fetch(k):
url = base64.decodestring("aHR0cDovL3NlYXJjaC5qZC5jb20vU2VhcmNoP2tleXdvcmQ9JXMmZW5jPXV0Zi04JndxPSVz") % ((urllib.quote(k),)*2)
ret = map(lambda l:[l.attrs.get('data-sku') or '']+map(lambda x: x.text.strip() if x else '',[l.select_one(css) for css in ['div.p-price i', 'div.p-name a']])+(lambda x: [x.attrs.get('src') or x.attrs.get('data-lazy-img')] if x else [''])(l.select_one('div.p-img a img')), BeautifulSoup
(urllib.urlopen(url), 'html.parser', from_encoding='utf-8').select("#J_goodsList ul li"))
return filter(lambda r: True if '' not in r else False, ret)
if name == "main":
for l in fetch('iphone'):
print l