def get_queryset(self): joined_list = [] trim_list = [] #urls = self.request.session['url'] userInput = self.kwargs['userInput'] list = {} list['Google News'] = GoogleNews(userInput)[:2] list['Yahoo Finance'] = YahooFinance(userInput)[:1] list['Wikipedia'] = wiki(userInput)[:] result = {} for (site, info) in list.iteritems(): joined_list = [] for item in info: result_dict=readArticle(item['url']) result_dict['original_source']=item['original_source'] joined_list.append(result_dict) #clean data trim_list = joined_list # for text in trim_list: # text['author'] =_(text['author']) # text['title'] = unicode(text['title']) # for p in text['people']: # p['name'] = (p['name']).encode('utf-8') # p['quotation'] = unicode(p['quotation']) # p['job_title'] = unicode(p['job_title']) result[site] = trim_list return result
def post(self, request, *args, **kwargs): if request.is_ajax() and request.method == 'POST': url = self.request.POST.get('url', '') original_source=self.request.POST.get('osource', '') Info = readArticle(url,original_source) context = {'success': True} Info['success'] = True # if len(Info)>0: # Info['success'] = True # else: # Info['success'] = False return self.get_json_response(self.convert_context_to_json(Info))