Вопрос

I am parsing feeds using feedparser and I am trying to store updated or updated_parsed attributes of feeds in Django db.

But it shows an error as [u'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.']

Please tell me how to convert updated and updated_parsed such that it can be stored in the Django db such that I can (convert and reuse) or just reuse the date stored in db while parsing in this way:

feedparser.parse("url", modified = lastupdate)
Это было полезно?

Решение 2

import time, datetime, feedparser, calendar
feed = feedparser.parse('www.popgadget.net')
feed_updated_date = datetime.datetime.utcfromtimestamp(calendar.timegm(feed.feed.updated_parsed)) 

Другие советы

Have you looked at datetime object?

You will need to use strptime() and strftime() to convert datetimes. http://docs.python.org/library/datetime.html#strftime-strptime-behavior

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top