I guess if you import enough libraries just about anything can be made into a one liner… if you have imported BeautifulSoup, re, requests, and sys, in python3 you can simply do: print(re.sub(r’^.*imgurl=([^&]+)&.*$’, r’\1′, str(BeautifulSoup(requests.get("http://images.google.com/search?num=50&hl=en&safe=off&site=&tbm=isch&source=hp&biw=1744&bih=1279&q=%s&oq=" % sys.argv[1]).text).find(href=re.compile("imgurl"))))) To find the first hit on a google image search with argv[1]. Google will probably change their URL images later today and it’ll stop working, but I wanted this for a random […]
Dec 072012