環境: python3 + image + urllib
獲取必應搜尋的內容,解析出裡面的背景位址
# 連線網路,返回資料
# 獲取每日的url
# 拼接
picurl = '' + picurl
picdata = connect_net(picurl)
# 擷取名字
piclist = str(picurl).split('/')
picname = piclist[len(piclist) - 1]
# 儲存到本地
with open(picname, 'wb') as f:
f.write(picdata)
print(picname)
return picname
import urllib.request
import re
from pil import image
# import win32gui
# import win32con
import win32api
# 連線網路
# 獲取每日的url
# 拼接
picurl = '' + picurl
picdata = connect_net(picurl)
# 擷取名字
piclist = str(picurl).split('/')
picname = piclist[len(piclist) - 1]
# 儲存到本地
with open(picname, 'wb') as f:
f.write(picdata)
print(picname)
return picname
if __name__ == '__main__' :
data = connect_net('/?mkt=zh-cn')
picurl = get_dailypicurl(data.decode('utf-8'))
picname = download_dailypic(picurl)
問題: 不能匯入win32gui? python爬取必應的桌布
閒著沒事。想找點桌布,於是用python寫個爬蟲來爬個桌布吧。1 收先安裝python環境 2.安裝所需要的三方庫 win下 pip install requests pip install beautifulsoup4 import requests import urllib.request i...
Python 爬取必應(桌布 搜尋詞)
效果如下 如下 import requests import re import os headers defget page num page list for i in range 1 num 1 url f return page list defget html url r requests...
每日自動切換桌布
python 如下 import requests import re import os headers def getphotourl host 解析主頁獲取大圖路徑 path dowloadphoto host,fileurl 接受返回的檔案路徑 print path str r reg ad...