首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >webdriver.chrome()模块:“TypeError”对象不可调用

webdriver.chrome()模块:“TypeError”对象不可调用
EN

Stack Overflow用户
提问于 2020-03-18 11:32:43
回答 1查看 916关注 0票数 0

我正在用python3编写亚马逊网络抓取脚本,所以我使用了selenium,但我得到了这个调试

代码语言:javascript
复制
webdriver.chrome()
TypeError: 'module' object is not callable 

我看到了要更改的解决方案(chrome到Chrome),但我也得到了这个调试

代码语言:javascript
复制
FileNotFoundError: [WinError 2] The system cannot find the file specified

这是我的代码

代码语言:javascript
复制
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
from selenium import webdriver

driver = webdriver.chrome()
driver.get('https://www.amazon.com/international-sales-offers/b/?ie=UTF8&node=15529609011&ref_=nav_navm_intl_deal_btn')
res = driver.execute_script("return document.documentElement.outerHTML")
driver.quit()
soup = BeautifulSoup(res , 'lxml')
box= soup.find('div',{'class':'a-row padCenterContainer widgetBorder'})
products=box.find_all('div',{'class':'a-section a-spacing-none tallCellView gridColumn5 singleCell'})
for details in products:
    name= details.find('span',{'class':'a-declarative'}).text
    link= details.find('a',{'class':'a-size-base a-link-normal dealTitleTwoLine singleCellTitle autoHeight'}).get('href')
    print(name,link)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-18 11:37:04

我认为应该是Chrome(),而不是chrome()。尝试:

代码语言:javascript
复制
from selenium import webdriver

driver = webdriver.Chrome()

你也可以将路径传递给你的Chromedriver,将executable_path设置为你的chromedriver所在的位置(指向chromedriver.exe的路径,或者,对于非Windows用户,它被称为chromedriver):

代码语言:javascript
复制
driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60733157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档