<form method="post" name="login_form" action="/submit">
我正在尝试获取我尝试过的动作属性
print fromstring(source).xpath('.//form[@action]')[0].text
,但可以打印
None
您的XPath表达式返回的是<form>
元素,而不是属性。
从元素获取属性:
print fromstring(source).xpath('.//form[@action]')[0].get('action')
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句