1

I have a php script on my webserver. When I call ..../myscript.php in the webserver, the script writes something into a file. How can I call this script from a python program, running on my computer... I tried different things request, subprocess etc. - nothing worked. Whatwould be the right way to do this?

Regards

Adriana

1 Answer 1

2

You have lot of methods to do this. One of them is using request:

import requests

url = "http://domain.name/script.php"
r = requests.get(url)

Or using urllib

import urllib
response = urllib.urlopen("http://domain.name/script.php")
data = response.read()
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you- I tried these. But the script isn't executed (the script in the script.php- when I call script.php from browser, it works)
Its impossible :) Maybe you need check your firewall? I think that Python haven't access to internet for some reason.

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.