Skip to content

Commit d00b072

Browse files
committed
- added headers and cookies parameters in the Analytics.extractArticleInfo() method
1 parent bd40776 commit d00b072

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Analytics. updated `trainTopicOnTweets()`, `trainTopicClearTopic()` and `trainTopicGetTrainedTopic()` methods in the `Analytics` class.
88
- `QueryArticles.initWithComplexQuery()` was updated - the parameter `dataType` was removed (since the `dataType` value should be provided in the `$filter` section of the query)
9+
- `TopicPage` now supports setting also the source rank percentile
10+
- `Analytics.extractArticleInfo` now also supports setting the headers and cookies to be used when making the requests
911

1012

1113

eventregistry/Analytics.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
NOTE: the functionality is currently in BETA. The API calls or the provided outputs may change in the future.
1111
"""
1212

13+
import json
1314
from eventregistry.Base import *
1415
from eventregistry.ReturnInfo import *
1516

@@ -75,17 +76,27 @@ def detectLanguage(self, text):
7576
return self._er.jsonRequestAnalytics("/api/v1/detectLanguage", { "text": text })
7677

7778

78-
def extractArticleInfo(self, url, proxyUrl = None):
79+
def extractArticleInfo(self, url, proxyUrl = None, headers = None, cookies = None):
7980
"""
8081
extract all available information about an article available at url `url`. Returned information will include
8182
article title, body, authors, links in the articles, ...
8283
@param url: article url to extract article information from
8384
@param proxyUrl: proxy that should be used for downloading article information. format: {schema}://{username}:{pass}@{proxy url/ip}
85+
@param headers: dict with headers to set in the request (optional)
86+
@param cookies: dict with cookies to set in the request (optional)
8487
@returns: dict
8588
"""
8689
params = { "url": url }
8790
if proxyUrl:
8891
params["proxyUrl"] = proxyUrl
92+
if headers:
93+
if isinstance(headers, dict):
94+
headers = json.dumps(headers)
95+
params["headers"] = headers
96+
if cookies:
97+
if isinstance(cookies, dict):
98+
cookies = json.dumps(cookies)
99+
params["cookies"] = cookies
89100
return self._er.jsonRequestAnalytics("/api/v1/extractArticleInfo", params)
90101

91102

0 commit comments

Comments
 (0)