Exemplo n.º 1
0
def getPdfLink():
    data = request.get_json()
    title = data['title']
    authors = data['authors']
    authors = " ".join(x for x in authors)

    r = Requester.scholarQuerier(title, authors=authors)
    scholarParser = ScholarParser(r.text, )
    searchResult = json.loads(scholarParser.parse(pdfIncluded=True))

    reply = {'msg': 'error'}
    if searchResult:
        firstResult = searchResult[0]
        resultTitle = firstResult['title']

        if Util.similar(title, resultTitle):
            reply['msg'] = "pdf"
            reply['pdflink'] = firstResult['pdflink']

            if reply['pdflink'] is None:
                reply['msg'] = "site"
                reply['sitelink'] = firstResult['sitelink']

    return json.dumps(reply)
Exemplo n.º 2
0
 def testSimilar2(self):
     a = "Cube data"
     b = "Data cube"
     self.assertEqual(Util.similar(a, b), False)
Exemplo n.º 3
0
 def testSimilar1(self):
     a = "Condensed cube"
     b = "Data cube"
     self.assertEqual(Util.similar(a, b), False)