我正在尝试使用Python Selenium刮Facebook的封面照片
它正确地返回URL,但是它被更改并显示模糊的URL。
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
url = 'https://www.facebook.com/events/851274783286508/?active_tab=about'
driver = webdriver.Edge()
driver.get(url)
cover_class = 'img.x1ey2m1c.x9f619.xds687c.x5yr21d.x10l6tqk.x17qophe.x13vifvy.xh8yej3'
img = driver.find_element(By.CSS_SELECTOR,cover_class)
print(img.get_attribute('src'))
requests.get(img.get_attribute('src'))
################## THIS IS THE URL THAT SHOULD BE RETURNED ################################
#perfect_src = https://scontent.fpsd2-1.fna.fbcdn.net/v/t39.30808-6/321296208_468127735500704_5967700403570897493_n.jpg?_nc_cat=106&ccb=1-7&_nc_sid=340051&_nc_eui2=AeFSxY7I0TKJvJRIx37yNz_jvkkF4L__0_G-SQXgv__T8a3A9q5B5t3jD54iDEhyayU7Wf-86Xko3e-lkPKiOl8v&_nc_ohc=kU48KdHWOFcAX_w-iW0&_nc_ht=scontent.fpsd2-1.fna&oh=00_AfCjDp7TSLV22b8WigiDlMedF9ONKuDXmW885vje3OAlMQ&oe=64573615
################## THIS IS THE ACTUAL IMAGE URL I'M GETTING ################################
#mehogcy_src = https://scontent.fpsd2-1.fna.fbcdn.net/v/t39.30808-6/321296208_468127735500704_5967700403570897493_n.jpg?stp=dst-jpg_fb50_s320x320&_nc_cat=106&ccb=1-7&_nc_sid=340051&_nc_ohc=kU48KdHWOFcAX_w-iW0&_nc_ht=scontent.fpsd2-1.fna&oh=00_AfDSvqeVreyDGTVq4If0dBtyBA6H1PA0YV9CVaY3DLnupg&oe=64573615
我该怎么补救?
我试图刮它使用 selenium ,因为它显示在所附的代码。
1条答案
按热度按时间olqngx591#
我只是改变了下面的行:
收件人:
所需进口:
结果:
当我点击控制台上打印的这个URL时,它打开如下: