-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created API for downloading arxiv papers
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import arxiv | ||
import pandas as pd | ||
|
||
def get_arxiv_data(query: str) -> str: | ||
""" | ||
Fetch papers through query or id and store them in local directory. | ||
Eventually needs to be ingested into database. | ||
""" | ||
|
||
search = arxiv.Search(query=query, | ||
max_results=10, | ||
sort_by = arxiv.SortCriterion.SubmittedDate) | ||
|
||
directory = os.path.join(os.getcwd(), 'arxiv_papers') | ||
if not os.path.exists(directory): | ||
os.makedirs(directory) | ||
|
||
for result in arxiv.Client().results(search): | ||
print("Downloading paper: ", result.title) | ||
result.download_pdf(dirpath=directory) | ||
|
||
|
||
return "success" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ unstructured==0.10.29 # causes huge ~5.3 GB of installs. Probbably from onnx: ht | |
|
||
# Not currently supporting coursera ingest | ||
# cs-dlp @ git+https://github.com/raffaem/[email protected] # previously called coursera-dl | ||
arxiv==2.0.0 |