1

我已经在这里待了一天。没有一个 Youtube 视频超出了一个非常基本的示例。请帮忙。我敢肯定我在这里错过了一些非常基本的东西。

如果输入框嵌入到表格中,它会改变吗?这是我的代码:

from robobrowser import RoboBrowser

br = RoboBrowser(history=True, parser = 'html.parser', user_agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11')
br.open('https://fbcad.org/Advanced-Search')
form = br.get_form(id='Form')
form['NameFirst'] = "john"
form['NameLast']  = "smith"
br.submit_form(form)

这是错误:

C:\Python\Python37\python.exe C:/Python/Python37/FBCAD.py
Traceback (most recent call last):
  File "C:/Python/Python37/FBCAD.py", line 7, in <module>
    form['NameFirst'] = "john"
  File "C:\Python\Python37\lib\site-packages\robobrowser\forms\form.py", line 216, in __setitem__
    self.fields[key].value = value
  File "C:\Python\Python37\lib\site-packages\werkzeug\datastructures.py", line 784, in __getitem__
    raise exceptions.BadRequestKeyError(key)
werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
4

1 回答 1

1

哇谢谢!事实证明,答案是不要在这个论坛上提问,而是花周末学习 Selenium 作为替代方案。感谢堆栈溢出!感谢机器人浏览器!

于 2018-07-30T14:37:40.977 回答