1
我嘗試使用表單解析輔助頁面。我使用的示例代碼源從這個鏈接: http://blog.ianbicking.org/2007/09/24/lxmlhtml/ 在我的測試我使用這個網址:http://www.infofer.ro/ 像例子中,我用這個值:我如何用lxml解析表單的結果頁?
>>> pprint(form.form_values())
[('cboData', '8/30/2010'),
('txtPlecare', 'Bucuresti Nord'),
('txtSosire', 'Constanta'),
('tip', 'GO'),
('lng', '1')]
結果採取與此:
result = parse(submit_form(form)).getroot()
這是另一種形式的另一頁。 我嘗試這樣:
>>> page2=parse(result).getroot()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/lxml/html/__init__.py", line 661, in parse
return etree.parse(filename_or_url, parser, base_url=base_url, **kw)
File "lxml.etree.pyx", line 2706, in lxml.etree.parse (src/lxml/lxml.etree.c:49945)
File "parser.pxi", line 1525, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:72026)
TypeError: cannot parse from 'HtmlElement'
如何我解析從二級頁面的形式?
問候。