fastdoi/semanticscholar.py

26 lines
1005 B
Python
Raw Normal View History

2024-08-20 11:07:07 +00:00
import requests
2024-08-22 11:34:46 +00:00
import random
import datetime
2024-08-20 11:07:07 +00:00
from config import __CONFIG__
def latest_release():
r2 = requests.get('https://api.semanticscholar.org/datasets/v1/release/latest').json()
return r2['release_id']
def first_pull():
res = requests.get('https://api.semanticscholar.org/datasets/v1/release/latest/dataset/abstract')
return res.json()
def abstract():
r3 = requests.get(headers={'x-api-key':__CONFIG__['semAPI']},url=
'https://api.semanticscholar.org/datasets/v1/release/latest/dataset/abstracts').json()
def search_paper(question):
query=""
for i in question:
query += "+" + i
res = requests.get(headers={'x-api-key':__CONFIG__['semAPI']},
2024-08-22 11:34:46 +00:00
url= 'https://api.semanticscholar.org/graph/v1/paper/search?fieldsOfStudy=Psychology&fields=abstract,citationStyles&minCitationCount='+str(random.randint(10, 500))+'&year='+str(random.randint(1900,datetime.datetime.now().year))+'-&query='+query[+1:]).json()
2024-08-20 11:07:07 +00:00
return res['data']