Passing command line parameters to python script from html page - python

I have a html page with text box and submit button. When somebody enters data in text box and click submit, i have to pass that value to a python script which does some operation and print output. Can someone let me now how to achieve this. I did some research on stackoverflow/google but nothing conclusive. I have python 2.7, Windows 10 and Apache tomcat. Any help would be greatly appreciated.
Thanks,
Jagadeesh.K

You need to use a python web-framework of some sort. I suggest giving Django project a try. It has a great tutorial.

Short answer: You can't just run a python script in the clients browser. It doesn't work that way.
If you want to execute some python when the user does something, you will have to run a web app like the other answer suggested.

Related

Python - Download Excel file from clickable "XLS" button of website without using Selenium

I am trying to write a program that goes to the following site and downloads the Excel file that automatically downloads when clicking the XLS button on the bottom of the page. To be honest, I am quite new to programming.
Site: https://echa.europa.eu/assessment-regulatory-needs
At first I tried using Selenium to let the program click itself through the browser and really click on the button. However, I think the website detects the usage of automated software and I cannot bypass the disclaimer that appears when opening the website.
Then I read some answers on the same topic where it is possible by using the requests module. However, I could not get it to work.
One thing I think I understood from this anwer was that you need to get the site/server where the data is requested from by inspecting the button with F12 in the browser. I tried this, and thought I had it, however I cannot get the code to function. I learnt from this answer that you need to give the referer as well, bu I think the referer from this file ist only partially written out, as it is "https://echa.europa.eu/assessment-regulatory-needs".
This answer explained the network process more in detail, howver I am not able to recreate it. Also, to be honest i do not fully understand what the API is and how to search for it.
I also found this answer, but it does not work for me either.
So I am asking for help on this, as I think that my HTML, Java, Website, Python knowledge is too tiny to see what I have to change to be able to download the excel file.

Django: Making python script run on button click and display output on html page

I have been working on making a python script that will run by clicking a button and then displaying the output in the Django html page. so far I have managed to make a button that will run the script but I am not able to display any results below is the code I have used, it runs the python script in shell but goes no further.
In my Views.py
def Yellow(request):
inp = request.POST.get('param')
out = run(['python', '/yellow_page_updated.py', inp], stderr=subprocess.DEVNULL)
print(out.stderr)
print("Finished!!")
return render('Yellow_Page.html', {'data1': out})
In my Urls.py
url(r'^Yellow', views.Yellow, name="Yellow")
if anybody can help or point me in the right direction i would be very grateful.
if ant other info is needed please let me know
Thanks for taking a look

How to create s custom window in Python to display an iframe?

For displaying video player I would like to create a custom window that shows the output of the iframe html code I give.How do I create it ? I use Python idle and Windows
Please give more details. What are you using to parse html code?
what are you using for an ui?
If you are really new... try some googles :)
Pywebview
This might help. But for referent please try and google before asking.

Automate filling HTML pop up forms in python

I am looking for resources or guide so that I could build a Python code to fill my ~2k online forms automatically. Sorry I dont have any script to share as many resources in which python code is written to go to form URL and fill it. Since in my case it is a pop up form it doesnt really have a real URL.
Please be kind, I am new to Python.
Is there a way to do something to imitate clicks on browser window and fill in new values in the form ?
You can imitate clicks in the browser using selenium https://realpython.com/modern-web-automation-with-python-and-selenium/. There are plenty of tutorials how to do that.
Other tools would be:
https://www.cypress.io/
http://wwwsearch.sourceforge.net/mechanize/
If you don't want to write code - an
extension in the browser: https://www.seleniumhq.org/projects/ide/

Can I use Python to run html

i am writing an HTML editor and would like to make a section so that you can view how it would look in web browser directly in the program is this possible?
Thanks so much
I wouldn't do this - your renderer will quickly differ from real browsers.

Categories

Resources