Compare commits
No commits in common. "7911e3f117dc15c6956b4d297293814702f90ec6" and "daca611f6afc9b7ae106f1bef2fea14fa2a44d1f" have entirely different histories.
7911e3f117
...
daca611f6a
|
|
@ -1,2 +0,0 @@
|
||||||
_cache/
|
|
||||||
__pycache__/
|
|
||||||
17
app.py
17
app.py
|
|
@ -1,6 +1,5 @@
|
||||||
from flask import Flask, Response, abort, request
|
from flask import Flask, Response, abort
|
||||||
from parsers.nvidia import NvidiaParser
|
from parsers.nvidia import NvidiaParser
|
||||||
from urllib.parse import urlparse
|
|
||||||
import os, time, threading
|
import os, time, threading
|
||||||
|
|
||||||
class ParserData:
|
class ParserData:
|
||||||
|
|
@ -83,19 +82,6 @@ indexPage += '</html>'
|
||||||
def index():
|
def index():
|
||||||
return indexPage
|
return indexPage
|
||||||
|
|
||||||
#@app.route('/favicon.ico')
|
|
||||||
#def favicon():
|
|
||||||
# referrer = request.referrer
|
|
||||||
# if referrer != None:
|
|
||||||
# u = urlparse(referrer)
|
|
||||||
#
|
|
||||||
# for parser in parsers:
|
|
||||||
# if parser.parser.URL == u.path:
|
|
||||||
# favi = parser.parser.favicon
|
|
||||||
# return Response(favi.content, mimetype=favi.headers['Content-Type'])
|
|
||||||
#
|
|
||||||
# abort(404)
|
|
||||||
|
|
||||||
runParserWorkers()
|
runParserWorkers()
|
||||||
|
|
||||||
for parser in parsers:
|
for parser in parsers:
|
||||||
|
|
@ -105,3 +91,4 @@ for parser in parsers:
|
||||||
if parser.rss == None:
|
if parser.rss == None:
|
||||||
abort(404)
|
abort(404)
|
||||||
return Response(parser.rss, mimetype='text/xml')
|
return Response(parser.rss, mimetype='text/xml')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ from feedgen.feed import FeedGenerator
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import requests
|
|
||||||
|
|
||||||
Entry = namedtuple('Entry', 'url fe')
|
Entry = namedtuple('Entry', 'url fe')
|
||||||
|
|
||||||
|
|
@ -11,18 +10,6 @@ class NvidiaParser:
|
||||||
NAME = 'NVidia Research'
|
NAME = 'NVidia Research'
|
||||||
URL = '/nvidia'
|
URL = '/nvidia'
|
||||||
CACHE_TIMEOUT = 3600
|
CACHE_TIMEOUT = 3600
|
||||||
root_url = 'https://research.nvidia.com'
|
|
||||||
favicon = None
|
|
||||||
|
|
||||||
def loadFavicon(self):
|
|
||||||
try:
|
|
||||||
favUrl = NvidiaParser.root_url + '/themes/custom/nvidia/favicon.ico'
|
|
||||||
self.favicon = requests.get(favUrl)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# def __init__(self):
|
|
||||||
# self.loadFavicon()
|
|
||||||
|
|
||||||
def parseNvidiaDate(entry):
|
def parseNvidiaDate(entry):
|
||||||
dom = pq(entry.url)
|
dom = pq(entry.url)
|
||||||
|
|
@ -33,20 +20,22 @@ class NvidiaParser:
|
||||||
entry.fe.pubDate(time)
|
entry.fe.pubDate(time)
|
||||||
|
|
||||||
def getRss(self):
|
def getRss(self):
|
||||||
d = pq(self.root_url +'/publications')
|
root_url = 'https://research.nvidia.com'
|
||||||
# self.loadFavicon()
|
d = pq(root_url +'/publications')
|
||||||
|
|
||||||
fg = FeedGenerator()
|
fg = FeedGenerator()
|
||||||
fg.id(self.root_url)
|
fg.id(root_url)
|
||||||
fg.title('NVidia Research')
|
fg.title('NVidia Research')
|
||||||
fg.link(href=self.root_url, rel='alternate')
|
fg.link(href=root_url, rel='alternate')
|
||||||
|
fg.logo(root_url + '/themes/custom/nvidia/favicon.ico')
|
||||||
fg.description('NVidia Research papers')
|
fg.description('NVidia Research papers')
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
|
print('RSS GOT')
|
||||||
|
|
||||||
for elem in d('.views-field-title').items():
|
for elem in d('.views-field-title').items():
|
||||||
link = elem.find('a')
|
link = elem.find('a')
|
||||||
url = self.root_url + link.attr.href
|
url = root_url + link.attr.href
|
||||||
title = link.text()
|
title = link.text()
|
||||||
|
|
||||||
fe = fg.add_entry()
|
fe = fg.add_entry()
|
||||||
|
|
@ -56,12 +45,8 @@ class NvidiaParser:
|
||||||
|
|
||||||
entries.append(Entry(url, fe))
|
entries.append(Entry(url, fe))
|
||||||
|
|
||||||
for entry in entries:
|
with multiprocessing.Pool(8) as p:
|
||||||
NvidiaParser.parseNvidiaDate(entry)
|
p.map(NvidiaParser.parseNvidiaDate, entries)
|
||||||
print(entry.url)
|
|
||||||
|
|
||||||
# with multiprocessing.Pool(8) as p:
|
|
||||||
# p.map(NvidiaParser.parseNvidiaDate, entries)
|
|
||||||
|
|
||||||
return fg.rss_str()
|
return fg.rss_str()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue