我正在学习进行网络抓取,并设法将数据从网页中提取到 excel 文件中。但是,可能是因为项目名称包含“,”,这使得excel文件中的项目名称变为多列。
我曾尝试在列表中使用剥离和替换元素,但它返回错误消息:AttributeError: 'WebElement' object has no attribute 'replace'。
item = driver.find_elements_by_xpath('//h2[@class="list_title"]')
item = [i.replace(",","") for i in item]
price = driver.find_elements_by_xpath('//div[@class="ads_price"]')
price = [p.replace("rm","") for p in price]