code.py
import requests | |
import json | |
jt = json.dumps({'trashed': True}) | |
url = 'https://api.mention.net/api/accounts/<account identifier>/alerts/<alert identifier>/mentions' | |
gh = {'Accept': 'application/json', 'Accept-Language': 'en', 'Authorization': 'Bearer <token>'} | |
ph = gh.copy() | |
ph['Content-Type'] = 'application/json' | |
finished = False | |
count = 1 | |
while not finished: | |
j = requests.get(url, headers=gh).json() | |
# the check for finished isn't really working | |
finished = j['reached_history_limit'] | |
for i in j['mentions']: | |
print count, i['id'], i['title'], requests.put(url + '/' + i['id'], headers=ph, data=jt) | |
count = count + 1 |