Reputation: 91
I am trying to grab a form action using beautiful soup
I have tried print(soup.find('form').find_all('action'))
but that doesnt work. Wondering if there is an easy way. ( I am trying to get the rest of the string after ?dwcont=
)
Upvotes: 1
Views: 635
Reputation: 71
action = soup.find('form').get('action')
print(action.split("?dwcont=",1)[1])
Upvotes: 0
Reputation: 780798
action
is an attribute, .find_all()
is for finding elements. Use ['action']
.
print(soup.find('form')['action'])
Upvotes: 1