Yo!
Recently, I faced with the task of sending various search requests to arxiv.org API on Java/Kotlin and as result of that, I and my mates had decided to realize it as an open-source library ArxivApiAccess.
A simple track to use it
例如,如果您想查找有关Java或Kotlin的最后20篇文章,可以按以下代码进行操作:
val request: SearchRequest = SearchRequest.SearchRequestBuilder
.create("Java", SearchField.ALL)
.or("Kotlin", SearchField.ALL)
.sortBy(SortBy.LAST_UPTATED_DATE)
.sortOrder(SortOrder.DESCENDING)
.maxResults(20)
.build()
val response: Feed = SearchRequestExecutor().executeAndMap(request)
println(response)
另外,您可以根据请求加载所有文章,然后将其保存到文件中,或者根据需要实现回调函数:
val subjectCategory = "astro-ph"
val fileToSave = "../arxiv_data_sets/${subjectCategory}.csv"
val request = SearchRequest.SearchRequestBuilder
.create(subjectCategory, SearchField.SUBJECT_CATEGORY)
.build()
loadAllByRequest(request, { feed ->
// Donwload to file
val writer = FileWriter(fileToSave, true)
writer.use {
feed.entry?.forEach {
val authorString = it.author.joinToString(", ") { author -> author.name }
val resultString = "${it.updated}|${subjectCategory}|${it.title}|${authorString}".replace("\n", "")
writer.write("${resultString}\n")
}
writer.close()
}
println("parsed ${feed.startIndex+feed.itemsPerPage}/${feed.totalResults}")
})
// return false to stop a process of the parsing
true
或者,您可以找到最近30天有关Java或Kotlin的所有文章:
val request: SearchRequest = SearchRequest.SearchRequestBuilder
.create("Java", SearchField.ALL)
.or("Kotlin", SearchField.ALL)
.build()
var list = searchAllAfterDate(request, Date(System.currentTimeMillis() - TimeUnit.MILLISECONDS.convert(30, TimeUnit.DAYS)))
println(list)
Getting started with Maven
<repository>
<id>myMavenRepoRead</id>
<url>https://mymavenrepo.com/repo/m3NxrnIEacYdXdF77zDL/</url>
</repository>
...
<dependency>
<groupId>olegthelilfix</groupId>
<artifactId>ArxivApiAccess</artifactId>
<version>${ArxivApiAccess.version}</version>
</dependency>
当前版本是0.2-RELEASE。 您可以在项目存储库中找到有关该项目的更多信息。
olegthelilfix / ArxivApiAccess
Library to make search requests to API of Arvix.org
The future of the project
The current version of the project is not final and I’m planning to continue the project. The first is to stabilize the current functionality. The second is to enhance the library's ability to interact with arxiv.org API and so on.
Fell free to write me about everything.