Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [daily_psg_report.py]
- #Import libraries
- import requests
- import http.client
- import datetime
- import Your-Postgres-Script
- #Declare date variable as string and format for URL
- now = datetime.datetime.now()
- dateStr = now.strftime("%m") + "%2" + now.strftime("%d") + "%2" + now.strftime("%Y")
- #Set HTTP variables
- httpHeaders = "HTTP/1.0 encoding = csv/xlsv"
- url = "http://cccis.com/report?from=" + dateStr + "&to=" + dateStr + "&otherParameters"
- authUser = "Username"
- authPass = "password"
- #Execute GET request by setting variable as the reponse
- resp = requests.get(url, headers=httpHeaders,auth=(authUser,authPass))
- #Pass response (as file) to function in your Postgres INSERT script
- postgresInsert(resp.content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement