from selenium import webdriver import time import random def parse_data(): divs = driver.find_elements(By.XPATH,'//div[@class="grid g-clearfix"]/div/div') # 所有的div标签 for div in divs: test = div.find_element(By.XPATH,'.//div[@class="row row-2 title"]/a').text # 商品名字 price = div.find_element(By.XPATH,'.//strong').text + '元' # 商品价格 deal = div.find_element(By.XPATH,'.//div[@class="deal-cnt"]').text # 付款人数 name = div.find_element(By.XPATH,'.//div[@class="shop"]/a/span[2]').text # 店铺名称 location = div.find_element(By.XPATH,'.//div[@class="location"]').text # 店铺地点 detail_url = div.find_element(By.XPATH,'.//div[@class="row row-2 title"]/a').get_attribute('href') # 详情页地址 print(test, price, deal, name, location, detail_url
爬虫name ‘driver‘ is not defined报错怎么解决
最新推荐文章于 2024-04-24 04:38:55 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)