File size: 1,587 Bytes
394e826
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import streamlit.components.v1 as components
import requests
import random
from bs4 import BeautifulSoup

def display_paper(link, title, pdf_link):
    st.title(f"Random Arxiv Paper: A randomly selected paper from Arxiv's newest published papers - {title}")  
    st.markdown(f"[Link to Paper]({link})")
    iframe_tag = f'<iframe src="{pdf_link}" width="1100" height="1000" scrolling="yes" seamless></iframe>'
    st.markdown(iframe_tag, unsafe_allow_html=True)

def main():
    with st.spinner("Wait for it..."):
        url = "https://arxiv.org/list/cs/new"

        response = requests.get(url)

        soup = BeautifulSoup(response.content, "html.parser")

        identifier_spans = soup.find_all("span", class_="list-identifier")

        links = []
        pdfs = []
        for span in identifier_spans:
            link = span.find("a")["href"]
            try:
                pdf_link = span.find("a", title="Download PDF")["href"]
                if link.startswith("/abs/"):
                    links.append("https://arxiv.org" + link)
                if pdf_link.startswith("/pdf/"):
                    pdfs.append("https://arxiv.org" + pdf_link + ".pdf")
            except:
                continue

        s = soup.find_all("div", class_="list-title mathjax")
        titles = [t.text for t in s]

        papers = list(zip(links, titles, pdfs))
        random_paper = random.choice(papers)
        paper_link, paper_title, paper_pdf = random_paper

    display_paper(paper_link, paper_title, paper_pdf)

if __name__ == "__main__":
    main()