3
這段代碼有什麼問題?它適用於duckduckgo.com,但不適用於谷歌,維基百科或雅虎。是的,我正在根據特定網站更改ID。Python RoboBrowser自動搜索功能
import re
from robobrowser import RoboBrowser
browser = RoboBrowser()
browser.open("https://en.wikipedia.org/wiki/Wikipedia")
# Must find the proper id in the html
form = browser.get_form(id = "searchInput")
form
form["searchval"].value = "Beethoven Opus 131"
browser.submit_form(form)
links = browser.get_links()
for link in links:
print(link)
print("Le Fin.")
我得到的每一次(除了duckduckgo.com)以下錯誤
line 16, in <module>
form["searchval"].value = "Beethoven Opus 131"
TypeError: 'NoneType' object is not subscriptable
我爲什麼在這裏得到NoneType
錯誤?我知道這個變量以前沒有定義過,但也沒有在Duckduckgo中定義。請幫忙。