search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

蝦皮購物 網站爬蟲 – ARON HACK 亞倫害的

使用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)
    


熱門推薦

本文由 aronhackcom 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦