[問題]Selenium沒辦法爬 MOMO購物網
各位大大好
如題小弟發現MOMO購物網有使用JS渲染
所以我使用Selenium Chromedriver的Headless方式去抓取
商品品名、價格、商品網址
可是不管用什麼方式
都沒辦法爬下來Q
以下是我的Code
from selenium import webdriver
from bs4 import BeautifulSoup
options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(executable_path =
r'/Users/syu/Downloads/chromedriver',chrome_options=options)
driver.get('https://www.momoshop.com.tw/search/searchShop.jsp?keyword=adidas')
ps = driver.page_source
ps = driver.page_source
soup = BeautifulSoup(ps,'lxml')
接下來嘗試用
items = driver.find_elements_by_css_selector('.prdName')
items = driver.find_elements_by_class_name('prdName')
items = soup.findAll('p',{'class':'prdName'})
怎麼抓都抓不到任何東西
已經試了一整天
也爬了很多文
但都還是找不到原因Q
真的麻煩各位大大了QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.177.147
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1544277113.A.A10.html
→
12/09 11:51,
5年前
, 1F
12/09 11:51, 1F
→
12/09 11:51,
5年前
, 2F
12/09 11:51, 2F
→
12/09 11:52,
5年前
, 3F
12/09 11:52, 3F
我加了停止時間五秒仍然抓不出來Q
Taki大是指用requests.get去抓那個頁面的原始碼的意思嗎
推
12/09 12:47,
5年前
, 4F
12/09 12:47, 4F
已修正,真的非常感謝!
※ 編輯: a6409tw (140.112.177.147), 12/09/2018 13:20:06
※ 編輯: a6409tw (140.112.177.147), 12/09/2018 13:23:41
→
12/09 18:16,
5年前
, 5F
12/09 18:16, 5F