-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
77 lines (67 loc) · 2.35 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import web
import urllib
import urllib2
import feedparser
import xml.etree.ElementTree as ET
import xpath
import HTMLParser
from bs4 import BeautifulSoup
import lxml.html
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
import sys
urls = (
'/', 'index',
'/result', 'result',
'/static/inputcss.css', 'css',
)
app = web.application(urls, globals())
class index:
def __init__(self):
self.render = web.template.render('template')
def GET(self, name=None):
return self.render.input("a")
def POST(self, name):
return "post"
class result:
def __init__(self):
self.render = web.template.render('template')
def GET(self, name=None):
i = web.input(query=None)
query = i.query.replace(" ", "+")
#query to CiteSeerx
s = "http://citeseerx.ist.psu.edu/search?q=" + query + "&submit=Search&sort=rlv&t=doc&feed=rss"
rss = feedparser.parse(s)
for entr in rss.entries:
entr.title = entr.title.replace("<em>", " ")
entr.title = entr.title.replace("</em>", " ")
entr.description = entr.description.replace("<em>", " ")
entr.description = entr.description.replace("</em>", " ")
#query to CiteSeerx Author
#s = "http://citeseerx.ist.psu.edu/search?q=" + query + "&submit=Search&uauth=1&sort=ndocs&t=auth"
#query to CSSeer
s = "http://csseer.ist.psu.edu/experts/show?query_type=1&q_term=" + query
doc = lxml.html.parse(s)
html = []
for node in doc.xpath("//div[@class='blockhighlight_box']"):
info = {}
s = 'http://citeseerx.ist.psu.edu'
s += ''.join((node.xpath("ul/li/a/@href")))
info['href'] = s
s = ''.join(node.xpath("ul/li/a/text()"))
info['name'] = s
#s = ''.join(node.xpath("table[@class='authInfo']/tr[contains(.,'Variations')]/td[2]/text()"))
#info['Variations'] = s
s =''.join(node.xpath("ul/li[2]/text()"))
info['Affiliations'] = s
#s = ''.join(node.xpath("table[@class='authInfo']/tr[contains(.,'Papers')]/td[2]/text()"))
#info['Papers'] = s
#s = ''.join(node.xpath("table[@class='authInfo']/tr[contains(.,'Homepage')]/td[2]/a/@href"))
#info['Homepage'] = s
html.append(info)
return self.render.result(rss, html)
class css:
def GET(self): raise web.seeother("/static/inputcss.css")
if __name__ == "__main__":
app.run()