为什么我的硒选择器拉字典?(Django / Python 3.8)



我刚刚在PythonAnywhere上更新了django应用中的selenium。这是我的代码:

from selenium import webdriver
def Synonym():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)
browser.get("https://www.synonym.com/synonyms/test")
test = browser.find_element_by_class_name("logo").text
browser.quit()
return test

但是它给了我一个错误:

AttributeError: 'dict'对象没有属性'text'

当我取出没有。text的文本时,结果是这样的:

{'ELEMENT': '0.3567871003333163-1'} 

我使用付费帐户,应该能够访问任何网站。旁注:有没有办法阻止硒从/tmp/文件和文件夹?

谢谢!

我对PythonAnywhere的修复是更新系统映像:https://help.pythonanywhere.com/pages/ChangingSystemImage

请回复!

最新更新