poojasujith
Posts: 1
Joined: Wed Jun 27, 2018 9:07 am

Data Transfer From HTML Page to Python File

Wed Jun 27, 2018 9:10 am

<html>
<body>
<form action="1.py">
Enter a No:<input type="number" name="t1"/><br/>
<input type="submit" value="CHECK"/>
</form>
</body>
</html>

I need the value of text box into the python file.


Give me a solution.

robbes
Posts: 144
Joined: Sun Jan 20, 2013 7:11 pm
Location: Canada - off the west coast

Re: Data Transfer From HTML Page to Python File

Wed Jun 27, 2018 4:34 pm

If you don't want to write your own script, you can use BeautifulSoup:

Code: Select all

from bs4 import BeautifulSoup

Code: Select all

soup = BeautifulSoup('your_html_file', "lxml")

Code: Select all

data_list = soup.findAll(text=True)
Use the requests module to generate 'your_html_file' if it a web site.
You should be able to find the item you want in data_list.

Return to “Python”