script to parse nzpug mail list
In [78]:
import requests
In [79]:
import xmltodict
import json
import random
import pandas
In [80]:
nzpreq = requests.get('https://groups.google.com/forum/feed/nzpug/topics/rss.xml?num=10')
In [81]:
convxml = xmltodict.parse(nzpreq.text)
In [82]:
totlen = len(convxml['rss']['channel']['item'])
In [83]:
ranint = random.randint(0, totlen)
In [ ]:
In [ ]:
In [ ]:
In [84]:
nzpubtit = convxml['rss']['channel']['item'][ranint]['title']
In [85]:
nzpund = nzpubtit.replace(' ', '_')
In [ ]:
In [88]:
pubd = convxml['rss']['channel']['item'][ranint]['pubDate']
In [ ]:
In [89]:
pandat = pandas.to_datetime(pubd)
In [90]:
str(pandat.date())
Out[90]:
In [91]:
savti = open('/home/wcmckee/nzpug/posts/' + nzpund + '.meta', 'w')
In [ ]:
In [92]:
savti.write(nzpubtit + '\n' + nzpund + '\n' + str(pandat.date()) + ' ' + str(pandat.time()))
Out[92]:
In [97]:
autho = convxml['rss']['channel']['item'][ranint]['author']
In [98]:
conlink = convxml['rss']['channel']['item'][ranint]['link']
In [99]:
condes = convxml['rss']['channel']['item'][ranint]['description']
In [100]:
savti.close()
In [101]:
savrst = open('/home/wcmckee/nzpug/posts/' + nzpund + '.rst', 'w')
In [102]:
savrst.write(nzpubtit + '\n' + autho + '\n' + condes)
Out[102]:
In [103]:
savrst.close()
In [ ]:
In [ ]:
In [68]:
str(pandat.time())
Out[68]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: