Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
LIMS-RSS
#!/usr/bin/env python3
import requests
import json
x=10
i=1
url = "http://lims.dccouncil.us/_layouts/15/uploader/AdminProxy.aspx/GetPublicAdvancedSearch"
payload = {"request":{"sEcho":1,"iColumns":4,"sColumns":"","iDisplayStart":0,"iDisplayLength":10,"mDataProp_0":"ShortTitle","mDataProp_1":"Title","mDataProp_2":"LegislationCategories","mDataProp_3":"Modified","iSortCol_0":0,"sSortDir_0":"asc","iSortingCols":0,"bSortable_0":True,"bSortable_1":True,"bSortable_2":True,"bSortable_3":True},"criteria":{"Keyword":"","Category":"","SubCategoryId":"","RequestOf":"","CouncilPeriod":"","Introducer":"","CoSponsor":"","ComitteeReferral":"","CommitteeReferralComments":"","StartDate":"","EndDate":"","QueryLimit":100,"FilterType":"","Phases":"","LegislationStatus":"10","IncludeDocumentSearch":False}}
headers = {"Content-Type": "application/json"}
r = requests.post(url, data=json.dumps(payload), headers=headers).json()['d']
d = json.loads(r)
outdata = []
outdata.append(d['aaData'])
while x*i < int(d['iTotalRecords']):
payload = {"request":{"sEcho":1,"iColumns":4,"sColumns":"","iDisplayStart":x*i,"iDisplayLength":10,"mDataProp_0":"ShortTitle","mDataProp_1":"Title","mDataProp_2":"LegislationCategories","mDataProp_3":"Modified","iSortCol_0":0,"sSortDir_0":"asc","iSortingCols":0,"bSortable_0":True,"bSortable_1":True,"bSortable_2":True,"bSortable_3":True},"criteria":{"Keyword":"","Category":"","SubCategoryId":"","RequestOf":"","CouncilPeriod":"","Introducer":"","CoSponsor":"","ComitteeReferral":"","CommitteeReferralComments":"","StartDate":"","EndDate":"","QueryLimit":100,"FilterType":"","Phases":"","LegislationStatus":"10","IncludeDocumentSearch":False}}
r = requests.post(url, data=json.dumps(payload), headers=headers).json()['d']
d = json.loads(r)
outdata.append(d['aaData'])
i += 1
rss_item = '<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>LIMS-RSS</title><description>An RSS feed for LIMS</description><link>https://esq.io/lims-rss.xml</link><atom:link href="https://esq.io/lims-rss.xml" rel="self" type="application/rss+xml"/>'
import html
from DateTime import DateTime
for measures in outdata:
# # print(measure)
for measure in measures:
date = DateTime(measure["Modified"]).rfc822()
out = {"id": measure["ID"], "title": measure["Title"], "description": html.escape(measure["ShortTitle"]), "link": "http://lims.dccouncil.us/Legislation/" + measure["Title"]}
rss_item += '<item><title>' + out['title'] + "</title><description>" + out['description'] + "</description><pubDate>" + date + "</pubDate><link>" + out['link'] + "</link><guid>" + out['link'] + "</guid></item>"
rss_item += '</channel></rss>'
with open('lims-rss.xml', 'w') as f:
f.write(rss_item)
# f.write(json.dumps(outdata))
with open('lims-rss.json', 'w') as f:
f.write(json.dumps(outdata, indent=2))
requests
DateTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment