-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from autonomio/add_arxiv_api
add arxiv API
- Loading branch information
Showing
6 changed files
with
53 additions
and
4 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.DS_Store | ||
*.pyc | ||
__pycache__ | ||
dedomena/*.pyc | ||
dedomena/*/*.pyc |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .twitter import twitter | ||
from .pubmed import pubmed | ||
from .arxiv import arxiv |
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,38 @@ | ||
def arxiv(keyword, n): | ||
|
||
'''Get articles with meta-data from ArXiv | ||
articles = arxiv('tibetan', 50) | ||
keyword | str | The string to be searched for in the title of the articles. | ||
n | int | Number of articles to return. | ||
''' | ||
|
||
import urllib | ||
import xmltodict | ||
import pandas as pd | ||
|
||
url = 'http://export.arxiv.org/api/query?search_query=all:' | ||
query = keyword + '&start=0&max_results=' + str(n) | ||
data = urllib.request.urlopen(url + query) | ||
results_xml = data.read().decode('utf-8') | ||
|
||
out = [] | ||
|
||
results_dict = xmltodict.parse(results_xml) | ||
|
||
results_list = results_dict['feed']['entry'] | ||
|
||
for i in range(len(results_list)): | ||
|
||
title = results_list[i]['title'] | ||
publication_date = results_list[i]['published'] | ||
abstract = results_list[i]['summary'] | ||
|
||
out.append([title, publication_date, abstract]) | ||
|
||
out = pd.DataFrame(out) | ||
out.columns = ['title', 'publication_date', 'abstract'] | ||
|
||
return out |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pandas | ||
pymed | ||
twintel | ||
pmlb | ||
pmlb | ||
xmltodict |
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