您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Selenium无法使用python抓取Shopee电子商务网站

Selenium无法使用python抓取Shopee电子商务网站

要使用Selenium和 _Python_提取Shopee]上的产品价格,您可以使用以下解决方案:

代码块:

from selenium import webdriver

from selenium.webdriver.support.ui import webdriverwait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC

options = webdriver.ChromeOptions() options.add_argument(‘–headless’) options.add_argument(‘start-maximized’) options.add_argument(‘disable-infobars’) options.add_argument(‘–disable-extensions’) browserdriver = webdriver.Chrome(chrome_options=options, executable_path=r’C:\WebDrivers\chromedriver.exe’) browserdriver.get('https://shopee.com.my/search?keyword=h370m’) webdriverwait(browserdriver, 20).until(EC.element_to_be_clickable((By.XPATH, “//div[@class=’shopee-modal__container’]//button[text()=’English’]”))).click() print([my_element.text for my_element in webdriverwait(browserdriver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, “//span[text()=’RM’]//following::span[1]”)))]) print(“Program Ended”)

控制台输出

['430.00', '385.00', '435.00', '409.00', '479.00', '439.00', '479.00', '439.00', '439.00', '403.20', '369.00', '420.00', '479.00', '465.00', '465.00']

Program Ended

python 2022/1/1 18:19:31 有408人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶