Created
November 21, 2015 21:14
-
-
Save itamarhaber/9a542c62204fdee62dd3 to your computer and use it in GitHub Desktop.
Trash Mention's alerts
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment