I'm trying to parse a feed with multiple events using the icalendar lib in python.
'summary' , 'description' and so on works fine, but for 'dtstart' and 'dtend' it's returning me:
icalendar.prop.vDDDTypes object at 0x101be62d0
def calTest():
req = urllib2.Request('https://www.google.com/calendar/ical/XXXXXXXXXX/basic.ics')
response = urllib2.urlopen(req)
data = response.read()
cal = Calendar.from_ical(data)
for event in cal.walk('vevent'):
date = event.get('dtstart')
summery = event.get('summary')
print str(date)
print str(summery)
return
What am I doing wrong? To use vobject its not a option, have to use the icalendar lib. Many thanks for any help for a python rookie.
The objects representing dtstart
and dtend
have an attribute dt
which contains a standard datetime.datetime
object.
start = event.get('dtstart')
print(start.dt)
A little late here, but if that helps: the API has been updated since (I did the same mistake // copy pasting another stackoverflow post) You need to use the method decoded() instead of get()
You can find the latest API reference to icalendar here : http://icalendar.readthedocs.io/en/latest/api.html
replace your call to get by decoded :
date = event.decoded('dtstart')
summery = event.decoded('summary')
It should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With