-3
我想創建一個腳本,它會自動下載當天的Bing壁紙,以便它可以成爲我的桌面背景,到目前爲止,我發現它的網址隱藏在g_img
標記中。所以我迄今爲止所做的是找到g_img={url: "
的位置,然後是下一個"
。在Python中,如何獲取位於另一個字符串的座標XY之間的子字符串?
from os.path import expanduser
import urllib
import os
HOME = expanduser("~")
os.system("wget https://www.bing.com")
str="g_img={url: \""
file="index.html"
pos=open(file, 'r').read().find(str)
pos2=open(file, 'r').read().find("\"", pos)
# function to get the url string
# function to get PicName
BingBackUrl= "https://www.bing.com%s" % url
urllib.urlretrieve(BingBackUrl, PicName)
os.system("gsettings set org.gnome.desktop.background picture-uri file://%s/%s" % (HOME, PicName))
你可以在輸入 - >輸出的形式發佈一個例子嗎? – MaLiN2223