圖片抓下來檔案無法顯示圖片?
我嘗試寫出抓圖的程式,運行結果是連結點進去圖有出現,但是檔案抓下來卻是空的,請問哪裡有問題
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) #<-圖片抓下來是空的
回答列表
-
2020/01/08 下午 11:52張維元 (WeiYuan)贊同數:0不贊同數:0留言數:0
a 抓下來是連結的字串吧?並不是圖檔?
-
2020/02/21 上午 00:44張富堯贊同數:1不贊同數:0留言數:0
print(a)出來的連結點進去是連到別人的google driver @@
如果pirnt(a)出來的網址是在一般網頁上可以開的才有辦法抓取