栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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:WebDriverschromedriver.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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/368584.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号