Posts: 2
Joined: Wed Jun 20, 2018 2:34 am

Single String Http Command Help

Wed Aug 29, 2018 4:09 pm

I have a driveway alarm running a a dry contact to a 3B+ GPIO input that notifies me over email of someone driving down our driveway. I would also like to use this to trigger the recording of a specific camera on my system through Blue Iris, which can accept http commands through a browser to trigger camera recording if typed as follows:


I've confirmed that it works fine on local devices when executed through a web browser. I'm trying to figure out the best way to incorporate this into a pi script that's triggered based on the GPIO. Running a script at startup to monitor the GPIO is easy, but I'm not overly experienced with http commands. Can anyone suggest how to send this type of command in a single string and what libraries to utilize?

Any help would be greatly appreciated!

User avatar
Posts: 1264
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: Single String Http Command Help

Wed Aug 29, 2018 9:04 pm

I recommend the command wget:

Code: Select all

wget http://localIP:port/admin?camera=West&trigger&user=admin&pw=xxxxxxxxxx -O myfile

The command curl could be an alternative too.


There is a python module named wget too:


Posts: 2
Joined: Wed Jun 20, 2018 2:34 am

Re: Single String Http Command Help

Wed Aug 29, 2018 10:40 pm

Thanks. I may give that a try. I have had some success with urllib, but there seems to be some issues when running it in shell versus running it from boot. I could get it running properly in a shell window when importing urllib.request, but the library couldn't be found when using a standard python shebang to call the python interpreter. It seems that urllib.request works with python3, though so I tried changing it to call python3, but still had the same error. It seems to work on boot if I would import the deprecated urllib rather than urllib.request and call with urllib.urlopen rather than urllib.request.urlopen, but then doesn't work in shell. That's a bit too buggy to me, so I may give the wget library option a try to simplify things.

Thanks again.

Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Single String Http Command Help

Thu Aug 30, 2018 9:17 am

Always use python-requests rather than urllib.
requests eliminates all the confusion between urllib/urllib2/etc
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Python”