Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run remote python script

Tags:

python

Its perhaps not the safest thing in the world to do, but assuming risks have been accounted for, what's the simplest way to load an run a python script that is http(s) hosted, from the local machine?

like image 580
Jasper Blues Avatar asked Sep 05 '26 13:09

Jasper Blues


1 Answers

# python 2
from urllib import urlopen
# python 3
from urllib.request import urlopen

page = urlopen('https://DANGEROUS').read()
exec(the_page)

EDIT: @jakekimds was right to point out that exec is more appropriate than eval here.

like image 128
axblount Avatar answered Sep 08 '26 02:09

axblount



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!