0

I implemented articles in application.py, but the articles I get have nothing in common with the staff articles for the same Postal Code 02138

https://ide50-username.cs50.io/articles?geo=02138

http://pset8.cs50.net/search?q=02138

@app.route("/articles")
def articles():
"""Look up articles for geo.*"""

# retrieve the geo argument from the HTML form
location = request.args.get("geo")

# checking for a missing argument triggering a runtime error
if not location:
    raise RuntimeError("Location is not specified")

articles = lookup(location)

# get only 5 articles 
pick_5 = articles[:5]

return jsonify(pick_5)

And the results: my version:

[
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNE1Pr6iZ8qnHKfjQiKdyXaSgf2v-w&clid=c3a7d30bb8a4878e06b80cf16b898331&ei=etpSWeCYF4efzAbTwYaABw&url=https://boston.eater.com/2017/6/27/15879174/blue-bottle-coffee-cambridge-opening", 
    "title": "Blue Bottle Arrives in Cambridge Later This Summer - Eater Boston"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNF-3S2yjPVnw02tO159eHKLnEQxKg&clid=c3a7d30bb8a4878e06b80cf16b898331&ei=etpSWeCYF4efzAbTwYaABw&url=http://www.weei.com/media/audio-channel/kc-who-are-all-these-people-calling-boston-racist-mut-pays-tribute-kirks-mom-6", 
    "title": "K&C - Who are all these people calling Boston racist? Mut pays tribute to Kirk's mom. 6-27-17 - WEEI.com"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNG3qAvTQ3lpqfOmb5RxgqQPcgE2RA&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779543681849&ei=etpSWeCYF4efzAbTwYaABw&url=http://abcnews.go.com/International/wireStory/suspect-slayings-sisters-brought-back-boston-48309867", 
    "title": "Suspect in slayings of sisters to be brought back to Boston - ABC News"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHWQh6JdFdqG5Yf4MtbUaUkSPBuwg&clid=c3a7d30bb8a4878e06b80cf16b898331&ei=etpSWeCYF4efzAbTwYaABw&url=http://www.metro.us/things-to-do/boston/cambridge-story-space", 
    "title": "Cambridge's Story Space turns 25 - Metro US"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNE0x0bQPqCsSQwfCg7eDh8DxBO5BA&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779543486063&ei=etpSWeCYF4efzAbTwYaABw&url=http://boston.cbslocal.com/2017/06/27/mitchell-chester-massachusetts-education-commissioner-death/", 
    "title": "Mitchell Chester, Massachusetts Education Commissioner, Dies At 65 - CBS Boston / WBZ"
  }
]

staff's version:

[
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNF2tqW5WBl774SIQ_cdZO9HR3HAbw&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779506282730&ei=aMcmWegH07_eAYXOtOAF&url=http://medford.wickedlocal.com/news/20170524/cambridge-police-medford-man-attacked-threatened-with-knife", 
    "title": "Cambridge police: Medford man attacked, threatened with knife - Wicked Local Medford"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNENha9zPg1pBHUggSeI6rx3VBfb7w&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779506988588&ei=aMcmWegH07_eAYXOtOAF&url=http://www.wbur.org/cognoscenti/2017/05/25/boston-history-slavery-kevin-c-peterson", 
    "title": "After New Orleans Removes Statue Of Robert E. Lee, Reckoning With Boston's Slave History - WBUR"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNGVrOzUv0LcVkq2_Yy3DFeIf5jIag&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779506226472&ei=aMcmWegH07_eAYXOtOAF&url=https://www.bostonglobe.com/business/2017/05/24/novartis-eliminating-data-jobs-cambridge/dhx9lTP4MZp4MuziW9H4SM/story.html", 
    "title": "Novartis eliminating 11 data jobs in Cambridge - The Boston Globe - The Boston Globe"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHcK-ni9x5rr5XHEoQf6IuB50jWvg&clid=c3a7d30bb8a4878e06b80cf16b898331&ei=aMcmWegH07_eAYXOtOAF&url=http://www.bizjournals.com/boston/news/2017/05/25/five-things-you-need-to-know-today-and-back-bays.html", 
    "title": "\u200bFive things you need to know today, and Back Bay's cutest new residents - Boston Business Journal"
  }, 
  {
    "link": "http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHYOTnrg8ouOr33PXHE9zamOZSAeQ&clid=c3a7d30bb8a4878e06b80cf16b898331&ei=aMcmWegH07_eAYXOtOAF&url=http://boston.cbslocal.com/2017/05/25/boston-serial-killer-theory-alcohol-bodies-in-water/", 
    "title": "Keller @ Large: Drinking Shouldn't Lead To Drowning - CBS Boston / WBZ"
  }
]

Completely different outputs. What is the problem? What is wrong with my implementation of /articles ?

By the way, Are articles randomly chosen? I am able to find my articles in Google News, but I can not find staff's articles in Google News

Any help is greatly appreciated ;)

Thanks!

3

That's old news. The staff's output, I mean. All the articles are a month old. It is reasonable to assume that the staff's solution has "features" that are unknown (and unknowable). As noted in the spec,

Additionally, you can search for location based news by modifying parameters in the URL, like the ones below. For a full list of parameters you can check out this guide.

This pset is far less prescribed than the earlier ones; there is no imperative to match a specific "data set", no check50. In fact:

You’re welcome to stylize your own app differently, but here’s what the staff’s solution looks like!

Don't sweat it. As long as you get articles from the location, you're good.

3
  • Phew, That is great. Thanks – wingedRuslan Jun 28 '17 at 8:03
  • @DinoCoderSaurus Hi there! I wonder if you could help me with a similar issue: my code returns a lot more articles than the staff solution.. The first few match up, which is reassuring, but where are all those extra ones might be coming from in my version, and does it even matter? Thanks. – Matvey Dec 25 '18 at 20:29
  • Oh, I just saw the "pick_5" in Ruslan's post! I don't see any mention of this in the spec though -- are we officially supposed to limit the number of articles to 5? – Matvey Dec 26 '18 at 0:05

You must log in to answer this question.

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