Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,35 +1,40 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
-
from
|
4 |
|
5 |
-
def
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
if
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
st.markdown(f"**Author(s):** {result['creator']}")
|
31 |
-
if 'dateofacceptance' in result.keys():
|
32 |
-
st.markdown(f"**Date of Acceptance:** {result['dateofacceptance']}")
|
33 |
-
st.markdown("---")
|
34 |
-
else:
|
35 |
-
st.write("No results found.")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
4 |
|
5 |
+
def search_arxiv(search_query: str, start: int = 0):
|
6 |
+
base_url = 'http://export.arxiv.org/api/query?'
|
7 |
+
query = f'search_query={search_query}&start={start}&max_results=10'
|
8 |
+
response = requests.get(base_url + query)
|
9 |
+
feed = BeautifulSoup(response.content, 'html.parser')
|
10 |
+
entries = feed.find_all('entry')
|
11 |
+
articles = []
|
12 |
+
for entry in entries:
|
13 |
+
article = {}
|
14 |
+
article['title'] = entry.title.text
|
15 |
+
article['authors'] = [author.find('name').text for author in entry.find_all('author')]
|
16 |
+
article['abstract'] = entry.summary.text
|
17 |
+
articles.append(article)
|
18 |
+
return articles
|
19 |
|
20 |
+
def get_paper_info(paper_id: str):
|
21 |
+
base_url = 'https://api.semanticscholar.org/v1/paper/'
|
22 |
+
response = requests.get(base_url + paper_id)
|
23 |
+
paper = response.json()
|
24 |
+
paper_info = {}
|
25 |
+
paper_info['title'] = paper['title']
|
26 |
+
paper_info['authors'] = [author['name'] for author in paper['authors']]
|
27 |
+
paper_info['abstract'] = paper['abstract']
|
28 |
+
paper_info['fieldsOfStudy'] = paper['fieldsOfStudy']
|
29 |
+
return paper_info
|
30 |
|
31 |
+
st.title('Scientific Data Substantiator')
|
32 |
+
search_query = st.text_input("Enter your search term")
|
33 |
|
34 |
+
if search_query:
|
35 |
+
articles = search_arxiv(search_query)
|
36 |
+
for article in articles:
|
37 |
+
st.write("Title: ", article['title'])
|
38 |
+
st.write("Authors: ", ", ".join(article['authors']))
|
39 |
+
st.write("Abstract: ", article['abstract'])
|
40 |
+
st.write("-----")
|
|
|
|
|
|
|
|
|
|
|
|