我试图提取所有的图像从一个OfferUp搜索 selenium ,但我已经尝试了一堆不同的代码,没有工作.我希望能够显示在另一个网站或弹出窗口中的所有图像,这样我就可以有一个更新的价格上OfferUp项目.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
# Driver path
chrome_driver_path = 'C:\\Users\gues\\OneDrive\\Desktop\\PyFiles\\chromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.maximize_window()
# Open webpage
wait = WebDriverWait(driver, 20)
openOfferUp = driver.get('https://offerup.com/search?q=dresser&DISTANCE=20&DELIVERY_FLAGS=p&PRICE_MAX=100')
#retrieve images
time.sleep(20)
images = driver.find_elements((By.TAG_NAME, 'img'))
image_urls = [image.get_attribute('src') for image in images]
for url in image_urls:
print(url)
time.sleep(1000)
字符串
2条答案
按热度按时间omqzjyyz1#
试试这个:
字符串
kh212irz2#
你可以试试这个:
字符串