我剛剛在 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'}
我使用的是付費帳戶,應該可以訪問任何網站。旁注:有沒有辦法阻止 selenium 制作 /tmp/ 檔案和檔案夾?
謝謝!
uj5u.com熱心網友回復:
我在 PythonAnywhere 上的修復是更新系統映像:https ://help.pythonanywhere.com/pages/ChangingSystemImage
回答禮貌caseneu!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/339604.html
