Saturday, February 5, 2011

How to do this with datetime & getpage in Python?

Hey guys, Currently having some problems-

now = datetime.datetime.now()
month = now.strftime("%B")


site = wikipedia.getSite('en', 'wikiquote')
page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:abc")

I need to get abc to change into the name of the month before it then tries to get the page, yet everything I try it gives an error of some sort.

How could I do it?

Thanks!

  • Would this work?

    page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:" + month)
    
    Solihull : Oh how easy it was! Thank you!
  • Did you try this:

    page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:%s" % month )
    
  • The page URL format is actually Wikiquote:Quote_of_the_day/Month. Try this:

    page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day/%s" % month)
    

0 comments:

Post a Comment