How can i get input value from html page
like
Using re
module to parse xml or html is generally considered as bad practice. Use it only if you are responsable for the page you try to parse. If not, either your regexes are awfully complex, or your script could break if someone replaces <input type="hidden" name=.../>
with <input name="..." type="hidden" .../>
or almost anything else.
BeautifulSoup is a html parser that :
Unless you have good reasons not to do it, you should use it rather than re
for HTML parsing.
For example assuming that txt
contains the whole page, find all hidden fields would be as simple as :
from bs4 import BeautifulSoup
soup = BeautifulSoup(txt)
hidden_tags = soup.find_all("input", type="hidden")
for tag in hidden_tags:
# tag.name is the name and tag.value the value, simple isn't it ?