小编rac*_*lll的帖子

JavascriptException:消息:javascript 错误:arguments[0].click 不是通过 Selenium 和 Python 使用 Arguments[0].click 的函数错误

我一直在抓取一些网站以获取进行网页抓取练习的位置。这段代码让我了解了酒店品牌的各个城市级别,但是每当我在代码中使用 driver.execute_script("arguments[0].click();", button) 时(如倒数第二行所示),我得到这个错误:

JavascriptException: Message: javascript error: arguments[0].click is not a function
Run Code Online (Sandbox Code Playgroud)

下面是我迄今为止编写的代码示例。

for state in state_links:
driver = Chrome(path_to_chrome_driver)
link = 'https://www.ihg.com/destinations/us/en/united-states/' + state.lower().replace(' ', '-')
driver.get(link)
city_links = driver.find_elements_by_xpath('//div[@class="countryListingContainer col-xs-12"]//ul//div//li//a//span')
city_links = [thing.text for thing in city_links]
driver.close()
for city in city_links:
    driver = Chrome(path_to_chrome_driver)
    link2 = 'https://www.ihg.com/destinations/us/en/united-states/' + state.lower().replace(' hotels', '').replace(' ', '-') + '/' + city.lower().replace(' ', '-')
    driver.get(link2)
    hotel_links = driver.find_elements_by_xpath('//div[@class="hotelList-detailsContainer"]//div//div//p//a')
    hotel_links = [elem.text for elem in hotel_links]
    driver.close()
    for hotel in hotel_links:
        driver …
Run Code Online (Sandbox Code Playgroud)

javascript python selenium webdriver selenium-webdriver

4
推荐指数
1
解决办法
2万
查看次数

python 中的 SQL COALESCE() 方法

我如何从 SQL 中重新创建 COALESCE() 方法,但在 python 中?

python sql

3
推荐指数
1
解决办法
8737
查看次数