Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import requests
- with open('users_regs.txt') as f:
- for line in f:
- value = line.split("\t")
- source = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A118898472&start-date=' + value[1] +'&end-date=' + value[2].strip('\n') +'&metrics=ga%3Asessions&dimensions=ga%3AsourceMedium%2Cga%3AdateHourMinute&sort=ga%3AdateHourMinute&filters=ga%3Adimension1%3D%3D' + value[0] +'&access_token=ya29.Gl3wBOWAecjWj4GgW0Gj920Sx2SBtVBkCHZjOsPNu6MWnN1XnsNwwzVzPVBcdVwDf_7lWJd0mege38pP1PSNvc9aBA7wbndUn-h6vqS5bbbEhSOKHp4cjQvVSQiN5R4'
- r = requests.get(source)
- l = json.loads(r.text)
- with open('users/' + value[0]+'.txt', 'w') as outfile:
- json.dump(l, outfile)
- try:
- for row in l["rows"]:
- print(value[0] + " " + row[0])
- break
- except:
- print(value[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement