1

I am trying to grab a form action using beautiful soup enter image description here

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= )

Zach C
  • 71
  • 1
  • 10

2 Answers2

1

action is an attribute, .find_all() is for finding elements. Use ['action'].

print(soup.find('form')['action'])
Barmar
  • 741,623
  • 53
  • 500
  • 612
0
action = soup.find('form').get('action')
print(action.split("?dwcont=",1)[1])

References

How to get a string after a specific substring?

Getting form "action" from BeautifulSoup result

talhoid
  • 61
  • 9