-3
私はデスクトップの背景になるように、その日のBingの壁紙を自動的にダウンロードするスクリプトを作成しようとしています。それまでのところ、URLは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))
例をinput - > outputの形で投稿できますか? – MaLiN2223