【发布时间】:2021-08-29 10:32:59
【问题描述】:
我想抓取页面上的评分和所有评论。但找不到路径。
enter code here
import urllib.request
from bs4 import BeautifulSoup
import csv
import os
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
import pandas as pd
import time
chrome_path =r'C:/Users/91940/AppData/Local/Programs/Python/Python39/Scripts/chromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_path)
driver.implicitly_wait(10)
driver.get("https://www.lazada.sg/products/samsung-galaxy-watch3-bt-45mm-titanium-i1156462257-
s4537770883.html?search=1&freeshipping=1")
product_name = driver.find_element_by_xpath('//*[@id="module_product_title_1"]/div/div/h1')
print(product_name.text)
rating = driver.find_element_by_xpath("//span[@class='score-average']")
print(rate.text)
review = driver .find_element_by_xpath('//*
[@id="module_product_review"]/div/div/div[3]/div[1]/div[1]')
print(review.text)
【问题讨论】:
-
只有第 1 页评论?
-
不需要所有的分页
-
QHarr !你能复习一下这个问题吗:stackoverflow.com/questions/68177444/…
标签: python pandas selenium web-scraping