从 urllib2 导入 ClientForm 导入 urlopen
page = urlopen('http://garciainteractive.com/blog/topic_view/topics/content/')
form = ClientForm.ParseResponse(page, backwards_compat=False)
print form[0]
问题是 ClientForm 通过以下方式解析第一个 html 表单:
<POST http://garciainteractive.com/blog/topic_view/topics/content/ application/x-www-form-urlencoded
<HiddenControl(ACT=1) (readonly)>
<HiddenControl(RET=http://garciainteractive.com/blog/topic_view/topics/content/) (readonly)>
<HiddenControl(URI=/blog/topic_view/topics/content/) (readonly)>
<HiddenControl(PRV=) (readonly)>
<HiddenControl(XID=d840927d4eaf95cef7aeca789009fb3991f574da) (readonly)>
<HiddenControl(entry_id=42) (readonly)>
<HiddenControl(site_id=1) (readonly)>
<CheckboxControl(save_info=[yes])>
<CheckboxControl(notify_me=[yes])>
<TextControl(captcha=)>
<SubmitControl(submit=Submit) (readonly)>>
因此,没有找到和name
输入。我该如何解决?TIAemail
url
更新:实际上,我没有单独使用 ClientForm,而是作为机械化的一部分,因此更喜欢允许在不重写机械化代码的情况下进行修复的解决方案