-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbatch_script.py
More file actions
executable file
·33 lines (30 loc) · 957 Bytes
/
Copy pathbatch_script.py
File metadata and controls
executable file
·33 lines (30 loc) · 957 Bytes
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
import urllib
import urllib2
import json
import ConfigParser
import sys
from fb_logger import FbGroupArchiver
def index():
config = ConfigParser.ConfigParser()
if(len(sys.argv)>2):
group_url = sys.argv[2]
elif(len(sys.argv)>1):
config.read(sys.argv[1])
group_url = config.get('group','url')
else:
print 'Usage: python batch_script.py [Config file name] [group page url(optional)]]'
return
data = urllib2.urlopen(group_url).read()
jsondata = json.loads(data)
while(group_url is not None):
FbGroupArchiver(sys.argv[1]).process_data(group_url)
data = urllib2.urlopen(group_url).read()
jsondata = json.loads(data)
if(jsondata.get('paging') is not None):
group_url = jsondata.get('paging').get('next')
print group_url
else:
print "Reached last page. Done."
break
if __name__ == "__main__":
index()