圖片抓下來檔案無法顯示圖片?
我嘗試寫出抓圖的程式,運行結果是連結點進去圖有出現,但是檔案抓下來卻是空的,請問哪裡有問題
import requests
from bs4 import BeautifulSoup
import re
rs=requests.get("https://docs.google.com/presentation/d/1iDLS1RYtjgaZhZeOwxmJ1cTOAkrc-PaY5zbH8D-aT7w/htmlpresent?hl=zh_TW")
so = BeautifulSoup(rs.text, 'html5lib')
ta = so.find_all("section")
for i in range(0,len(ta)):
s=ta[i]["style"]
ss=re.compile('pageid=(.*)&rev').findall(s)
print(ss)
with open(str(i)+".jpg","w") as f:
a="https://docs.google.com/presentation/u/0/d/1iDLS1RYtjgaZhZeOwxmJ1cTOAkrc-PaY5zbH8D-aT7w/viewpage?hl=zh_TW&pageid="+ss[0]+"&rev=1&hmac=ALf4PZ6jUYlvnsGOlFKwLfAdLGXz31P79Q&w=960&h=720&format=png&showText=0"
print(a) #<-顯示的連結是可以用的
f.write(a) #<-圖片抓下來是空的