-
Notifications
You must be signed in to change notification settings - Fork 57
Get Article Information
When you want to find details about a specific article you can use the QueryArticle class.
An example use of the QueryArticle() class to obtain details about the article with URI 247634888 would be:
from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = QueryArticle("247634888")
# get core article information
q.setRequestedResult(RequestArticleInfo())
res = er.execQuery(q)The resulting JSON object contained in res will contain:
{
"247634888": {
"info": {
"lang": "por",
"body": "...",
"title": "...",
"url": "...",
"uri": "...",
"eventUri": "...",
"time": "...",
"date": "...",
// other properties of the article (see Article data model)
}
}
}The returned information about the article follows the Article data model.
QueryArticle constructor accepts the article URI (or a list of URIs) and optionally the requested result:
QueryArticle(articleUriOrUriList, requestedResult = None)-
articleUriOrUriList: a string representing a single article URI or a list of article URIs (at most 200). Article URIs are returned by the various search queries; if you only know the article URL, you can obtain its URI using the ArticleMapper class. -
requestedResult: the information about the article to return. Can be any of theRequestArticle*classes described below. IfNone, then theRequestArticleInfo()instance will be set.
There is also a static method QueryArticle.queryByUri(articleUriOrUriList) that creates the same query from a single article URI or a list of article URIs.
QueryArticle class provides a method setRequestedResult() that can be used to specify which details about the article you wish to obtain. The argument in the method call has to be an instance that has a base class RequestArticle. Below are the classes that can be specified in the setRequestedResult() calls:
RequestArticleInfo
RequestArticleInfo(returnInfo = ReturnInfo())RequestArticleInfo class can provide the available information about the article - the title, body, date, concepts, event membership, ...
-
returnInfo: sets the properties of various types of data that should be returned about the article (concepts, categories, news source, ...)
RequestArticleSimilarArticles
RequestArticleSimilarArticles(page = 1,
count = 20,
lang = None, # None is interpreted as ["eng"]
limitPerLang = -1,
returnInfo = ReturnInfo())RequestArticleSimilarArticles returns a list of similar articles according to the CCA similarity.
-
page: which page of the similar articles to return (starting from 1). -
count: number of similar articles to return (max 200). -
lang: languages in which the returned similar articles should be. -
limitPerLang: the maximum number of articles to return per language (-1 for no limit). -
returnInfo: sets the properties of various types of data that is returned (articles, concepts, categories, news sources, ...)
RequestArticleDuplicatedArticles
RequestArticleDuplicatedArticles(page = 1,
count = 20,
sortBy = "cosSim", sortByAsc = False,
returnInfo = ReturnInfo(articleInfo = ArticleInfoFlags(bodyLen = -1)))RequestArticleDuplicatedArticles returns a list of articles that are duplicates of the specified article.
-
page: which page of the duplicated articles to return (starting from 1). -
count: number of duplicated articles to return (max 200). -
sortBy: how are the articles sorted. Options:id,date,cosSim,fq,socialScore,facebookShares,twitterShares. -
sortByAsc: should the results be sorted in ascending order. -
returnInfo: sets the properties of various types of data that is returned (articles, concepts, categories, news sources, ...)
RequestArticleOriginalArticle
RequestArticleOriginalArticle(returnInfo = ReturnInfo(articleInfo = ArticleInfoFlags(bodyLen = -1)))If the queried article is a duplicate, RequestArticleOriginalArticle returns the details of the original article.
-
returnInfo: sets the properties of various types of data that is returned about the original article.
Core Information
Usage tracking
Terminology
EventRegistry class
ReturnInfo class
Data models for returned information
Finding concepts for keywords
Filtering content by news sources
Text analytics
Semantic annotation, categorization, sentiment
Searching
Searching for events
Searching for articles
Searching for mentions
Article/event info
Get event information
Get article information
Other
Supported languages
Different ways to search using keywords
Topic pages
Feed of new articles/events
Social media shares
Daily trends
Find the event for your own text
Article URL to URI mapping