Browse Source

Created NYtimes script.

Marco Quezada 10 years ago
parent
commit
71f5c43c15
2 changed files with 25 additions and 2 deletions
  1. 4 2
      gulpfile.js
  2. 21 0
      hackathon_starter/hackathon/scripts/nytimes.py

+ 4 - 2
gulpfile.js

@@ -1,10 +1,12 @@
 // 1. Include gulp
 var gulp = require('gulp');
 
-// 2. Include any plugins you might need.
+// 2. Include any plugins you might need. 
+// NOTE: child_process is NOT a plugin but it is a requirement.
 var process = require('child_process');
 var install = require("gulp-install");
-// 3. Write out the tasks 
+
+// 3. Write out the tasks. 
 
 gulp.task('bowerinstall',function(){
 	console.info('Installing Bower Packages.')

+ 21 - 0
hackathon_starter/hackathon/scripts/nytimes.py

@@ -0,0 +1,21 @@
+'''module containing a handful of methods for aggregating
+data from the NY Times.'''
+
+import requests
+import json
+
+def fetcharticle(apikey, url):
+    '''returns the JSON data of the most
+    popular articles by view from the past 24 hours.'''
+    req = requests.get(url)
+    data = json.loads(req.content)
+    parsedData = []
+    stockData = {}
+    for datum in data:
+    	stockData = ['title'] = data['title']
+    	stockData = ['abstract'] = data['abstract']
+    	stockData = ['section'] = data['section']
+    	stockData = ['byline'] = data['byline']
+    	stockData = ['views'] = data['views']
+    parsedData.append(stockData)
+    return parsedData