<form method="post" name="login_form" action="/submit">
I'm trying to get the action attribute I've tried
print fromstring(source).xpath('.//form[@action]')[0].text
, but it prints
None
Your XPath expression returns the <form>
element , not the attribute.
Get the attribute from the element:
print fromstring(source).xpath('.//form[@action]')[0].get('action')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.