0

In pset8 mashup, the lookup route in helpers.py has a code that has something to do with the rss feed and the url parsing. Can someone make me understand the line of code below like how it goes to the url and the parsing, format and the urllib.parse.quote method ?

feed = feedparser.parse("https://news.google.com/news/rss/local/section/geo/{}".format(urllib.parse.quote(geo, safe="")))
0

As with arithmetic, it might be easiest to unravel this by evaluating from the inside out.

  1. urllib.parse.quote(geo, safe=""). quote is a urllib.parse method, doc found here. In this example, the (contents of) the variable geo are being made "safe" for the url (to prevent mischief, presumably).

  2. format is a python string method doc found here. In this example, the {} in the "https://....." string is being replaced with the result of urllib.parse.quote.....

  3. Finally, parse is a feedparser method description found here. It "goes to the URL" because, well, that's what it's built to do.

1
  • Thank you, your answer explains all of my queries. – sk.76 Aug 25 '18 at 6:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .