Sophia111 Sophia111 - 3 months ago 10
Linux Question

Sending parameters to a remote server via python script

I'm learning python these days, and I have a rather basic question.

There's a remote server where a webserver is listening in on incoming traffic. If I enter a uri like the following in my browser, it performs certain processing on some files for me:

//223.58.1.10:8000/processVideo?container=videos&video=0eb8c45a-3238-4e2b-a302-b89f97ef0554.mp4


My rather basic question is: how can I achieve sending the above dynamic parameters (i.e. container = container_name and video = video_name) to 223.58.1.10:8000/processVideo via a python script?

I've seen ways to ping an IP, but my requirements are more than that. Guidance from experts will be very helpful. Thanks!

Answer
import requests
requests.get("http://223.58.1.10:8000/processVideo",data={"video":"123asd","container":"videos"})

I guess ... its not really clear what you are asking ...

Im sure you could do the same with just urllib and/or urllib2

import urllib
some_url = "http://223.58.1.10:8000/processVideo?video=%s&container=%s"%(video_name,container_name)# you should probably use urllib urllencode here ...

urllib.urlopen(some_url).read()
Comments