32 lines
741 B
Python
32 lines
741 B
Python
#!/bin/python
|
|
|
|
import requests
|
|
import datetime
|
|
from sys import argv
|
|
|
|
now = datetime.datetime.now()
|
|
year, month, day = now.year, now.month, now.day
|
|
hour, minute, second = now.hour, now.minute, now.second
|
|
|
|
if month < 10:
|
|
month = str('0' + str(month))
|
|
if day < 10:
|
|
day = str('0' + str(day))
|
|
if hour < 10:
|
|
hour = str('0' + str(hour))
|
|
if minute < 10:
|
|
minute = str('0' + str(minute))
|
|
if second < 10:
|
|
second = str('0' + str(second))
|
|
|
|
response = requests.get("http://10.3.141.94/capture")
|
|
|
|
|
|
|
|
filename = str(year) + str(month) + str(day) + '-' + str(hour) + str(minute) + str(second) + '.jpg'
|
|
file = open(filename, "wb")
|
|
file.write(response.content)
|
|
file.close()
|
|
if len(argv) > 1:
|
|
print(filename + ' saved')
|