def img_parse(response):
html = bsp(response.text,"html.parser")
ig = 0
personal_id = bsp.find_all(html,"div",{"id":r.compile(r'post_\d+')})
if (os.path.exists(file_path)) == False:
os.makedirs(file_path)
for idx in personal_id:
ig += 1
avatar = bsp.find(idx,"div",{"class":"avatar"})
photo = session.post(bsp.find(avatar,"img")['src'],data,headers = headers)
print(photo)
img_name = file_path + str(ig) + ".jpg"
with open(img_name,'wb') as f:
f.write(photo.content)
f.flush()
f.close()
return print("ok")
我成功進入頁面且抓取到了照片的網址,但是進行請求後卻發生 ERRORThe requested URL could not be retrieved
令人痛心疾首,我一開始以為是圖片位址損壞,但後來發現有些照片直接訪問是可以看到的,但如果用request就只會跑到上面那個頁面,所以請大神們幫幫忙,可以解釋這到底是我的問題?還是網站本身的問題?