python';s mechanize无法正确解析表单

python';s mechanize无法正确解析表单,python,parsing,mechanize,Python,Parsing,Mechanize,我试图使用python的mechanize提交表单,但它无法正确解析所讨论的表单。除了这一个表单之外,还有4个其他表单被正确解析。虽然在perl的www::mechanize中对表单进行了正确的解析,但我希望继续使用python 是否有办法检索页面的html并对其进行编辑,然后让mechanize根据检索到的html解析并提交表单?如果其他人感兴趣。在mechanize的常见问题中找到了答案 或者,您可以任意处理HTML(和标题): browser = mechanize.Browser() b

我试图使用python的mechanize提交表单,但它无法正确解析所讨论的表单。除了这一个表单之外,还有4个其他表单被正确解析。虽然在perl的www::mechanize中对表单进行了正确的解析,但我希望继续使用python


是否有办法检索页面的html并对其进行编辑,然后让mechanize根据检索到的html解析并提交表单?

如果其他人感兴趣。在mechanize的常见问题中找到了答案

或者,您可以任意处理HTML(和标题):

browser = mechanize.Browser()
browser.open("http://example.com/")
html = browser.response().get_data().replace("<br/>", "<br />")
response = mechanize.make_response(
    html, [("Content-Type", "text/html")],
    "http://example.com/", 200, "OK")
browser.set_response(response)
browser=mechanize.browser()
浏览器。打开(“http://example.com/")
html=browser.response().get_data().replace(“
”,“
”) 响应=机械化。作出响应( html,[(“内容类型”,“文本/html”)], "http://example.com/“,200,“好的”) 浏览器。设置_响应(响应)