魔头
import httplib2 import os.path h = httplib2.Http('cache') headers = {'Content-type': 'application/x-www-form-urlencoded'} url = 'http://www.bing.com/' response, content = h.request(url, 'GET') htmlContent = content.decode('utf-8') imageUrl = htmlContent[htmlContent.find(';g_img'):] imageUrl = imageUrl[imageUrl.find("'") + 1:] imageUrl = imageUrl[:imageUrl.find("'")] imageUrl = imageUrl.replace('1366x768', '1920x1080') print(imageUrl) response, content = h.request(imageUrl, 'GET') imageFile = open(os.path.basename(imageUrl), 'wb') imageFile.write(content) imageFile.close()
查看详细资料
TOP