蝦皮購物 網站爬蟲

目錄

    原始文章

    蝦皮購物 網站爬蟲


    使用Selenium和BeautifulSoup,搜尋「後背包」,並抓出第一頁所有搜尋結果的月銷售量。

    shopee_url = 'https://shopee.tw/'
    from selenium import webdriver
    driver = webdriver.Chrome()
    driver.get(shopee_url)
    q = driver.find_element_by_class_name('shopee-searchbar-input__input')
    q.send_keys('後背包')
    from selenium.webdriver.common.keys import Keys
    q.send_keys(Keys.RETURN)
    from bs4 import BeautifulSoup
    soup = BeautifulSoup(driver.page_source,'lxml')
    links = soup.find_all(class_="shopee-search-item-result__item")
    
    for link in links:
       driver.get(shopee_url+link['href'])
       soup_lv2 = BeautifulSoup(driver.page_source,'lxml')
       selling_data = soup_lv2.find_all("div", "shopee-product-info__header__sold-count")
       print(selling_data)
        


    推薦文章

    Aron

    搭載商業思維的資料科學家,工業設計系畢業,曾任職知名品牌行銷企劃。下班後寫機器學習模型,寫網站,也寫文章。興趣是把Side Project當成創業題目來玩,把人生當成遊戲破關。

    facebook telegram

    推薦書單

    好懂秒懂的財務思維課
    好懂秒懂的財務思維課 ⭐⭐⭐⭐
    禁咒師 卷壹〈新裝版〉
    禁咒師 卷壹〈新裝版〉 ⭐⭐⭐⭐⭐
    人生複本
    人生複本 ⭐⭐⭐⭐⭐
    我輩中人: 寫給中年人的情書
    我輩中人: 寫給中年人的情書 ⭐⭐⭐⭐

    發佈留言

    • * 表示必填欄位
    • 您填寫的電子郵件不會被公開
    • 請確認您的電子郵件正確無誤,當您的留言收到新的回覆時,我們會寄送通知信件給您

    發佈留言必須填寫的電子郵件地址不會公開。