Last active
March 27, 2018 07:01
-
-
Save glader/27ebc4ac684158909b5ec8088f66ebc3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
from urllib import urlencode | |
token = 'AQAA...' | |
ids = ( | |
(554433, 'site1.ru'), | |
(334455, 'site2.ru'), | |
(443356, 'site3.ru'), | |
) | |
params = ( | |
('oauth_token', token), | |
('metrics', 'ym:s:visits'), | |
('dimensions', 'ym:s:month'), | |
('date1', '2018-02-01'), | |
('date2', '2018-02-28'), | |
) | |
for i, host in ids: | |
p = list(params) | |
p.append(['ids', i]) | |
url = 'https://api-metrika.yandex.ru/stat/v1/data?' + urlencode(p) | |
print host, | |
response = requests.get(url) | |
print response.json()['totals'][0] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment