2

I want to run a Python program on a website opened in Chrome, like in case of JavaScript I can run my code in DevTools. How to do it in case of Python?

Actually what I want to do is that there is some website opened already on chrome and my python script(I have used selenium in the script) wants to do something on that site , How to do this. I don't want to open site also through script but open it manually and then run the script.How can I do this ?

5
  • Okay .I wil take care next time. Commented May 20, 2019 at 19:11
  • Actually what I want to do is that there is some website opened already on chrome and my python script wants to do something on that site ,but I don't want to open site also through script but open it manually and then run the script. What to do ?? Commented May 20, 2019 at 19:12
  • 1
    The point of my feedback is for you to fix it for this question AND all future questions. Your question is 2 votes away from getting closed, likely due to the lack of information. Commented May 20, 2019 at 19:14
  • ok thanks for your feedback. I will definitely take care in future too. Commented May 20, 2019 at 19:18
  • 1
    Now you've turned one question into two (which is against site policy) and neither has any of the details that are required. See my first comment, read the links, and update your question properly. Commented May 20, 2019 at 19:20

2 Answers 2

1

Browsers don't natively support python. You'd have to run it on a server, which can be hard to set up.

This PHP code should work, although it's very insecure:

<?php
   $output =  exec('./file.py');
?>
Sign up to request clarification or add additional context in comments.

3 Comments

Actually what I want to do is that there is some website opened already on chrome and my script wants to do something on that site ,but I don't want to open site also through script but open it manually and then run the script. What to do can you elaborate ?
You cannot run python in a browser. If you want to interact with a website, use a scraper along with something like selenium to interact with the javascript
Yeah I have used selenium but what it does is that it when I run the python script it opens a website and then my further code runs over it. But what I want is that to open the webpage on my own and then run a script which does the task I was doing earlier with my script on webpage. How to do it ?
1

You can try this link : https://jupyter.org .

But this is only to embedded system and jupyter provides output to the webpage. That output is generated but some server services not really in browser.

You can't run python code like javascript. You can’t run python in browser because it is not supported simple. Python is more like server languages. You can do anything just like with c++ in native form not web. Browsers are sandbox's. On web platform you can't go out of browser also you can't access with other language's.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.