|
@@ -0,0 +1,35 @@
|
|
1
|
+import json
|
|
2
|
+from facebook_scraper import get_posts
|
|
3
|
+
|
|
4
|
+FILE = 'facebook_data.json'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+def scrape_data():
|
|
8
|
+ post_list = []
|
|
9
|
+ for post in get_posts('amicale.deseleves', pages=3):
|
|
10
|
+ print(post)
|
|
11
|
+ cleaned_post = {
|
|
12
|
+ "post_id": post["post_id"],
|
|
13
|
+ "post_text": post["post_text"],
|
|
14
|
+ "post_url": post["post_url"],
|
|
15
|
+ "image": post["image"],
|
|
16
|
+ "video": post["video"],
|
|
17
|
+ "link": post["link"],
|
|
18
|
+ "time": post["time"].timestamp(),
|
|
19
|
+ }
|
|
20
|
+ post_list.append(cleaned_post)
|
|
21
|
+ return post_list
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+def write_data(data):
|
|
25
|
+ with open(FILE, 'w') as f:
|
|
26
|
+ json.dump(data, f)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+def main():
|
|
30
|
+ print("Fetching facebook data...")
|
|
31
|
+ write_data(scrape_data())
|
|
32
|
+ print('DONE')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+main()
|