Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python mechanize引发BrowserStateError_Python_Mechanize - Fatal编程技术网

Python mechanize引发BrowserStateError

Python mechanize引发BrowserStateError,python,mechanize,Python,Mechanize,我有以下代码: br = mechanize.Browser() br._factory.is_html = True br.form = mechanize._form.ParseString('<form method="post"</form>', 'http://localhost/post.php')[1] br.form.new_control('text', 'test',{'value':'something'}) br.form.fixup() br.sub

我有以下代码:

br = mechanize.Browser()
br._factory.is_html = True
br.form = mechanize._form.ParseString('<form method="post"</form>', 'http://localhost/post.php')[1]

br.form.new_control('text', 'test',{'value':'something'})
br.form.fixup()
br.submit()
br=mechanize.Browser()
br.\u factory.is\u html=True

br.form=mechanize.\u form.ParseString(“显然,
mechanize
要求您有实际响应才能提交表单:

def viewing_html(self):
    """Return whether the current response contains HTML data."""
    if self._response is None:
        raise BrowserStateError("not viewing any document")
    return self._factory.is_html
()