-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFishPlease
More file actions
36 lines (32 loc) · 1.16 KB
/
FishPlease
File metadata and controls
36 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import requests
import datetime
import csv
import argparse
import os
import time
from datetime import datetime
import pandas as pd
from requests.packages.urllib3.exceptions import InsecureRequestWarning
result = []
URL = 'https://api.groupme.com/v3'
TOKEN = ''
params = {}
counter = 141055961931457390#FirstMessage
#1572013198
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
while int(counter) < 157196703975514846: #LastMessage
params = {'after_id' : counter, 'limit' : 100}
uu = URL + '/groups/' + 'agroupnumber' + '/messages' + '?token=atoken'
response = requests.get(uu, params=params, verify=False)
json_data = json.loads(response.text)
lastint = len(json_data['response']['messages'])
counter = json_data['response']['messages'][lastint-1]['id']
#time.sleep(10)
result.append(json_data)
print(counter)
# counter = msgs.content.response.messages[msgs.json().response.messages.length-1].id
# if you encounter a "year is out of range" error the timestamp
# may be in milliseconds, try `ts /= 1000` in that case
with open("merged_file.json", "w", encoding="utf8") as outfile:
json.dump(result, outfile)