Commit ae1adcd6e5de1e0f4212939111042adfc3a7525f

Authored by Noah ago
1 parent 20ade19ecb
Exists in master

페이지키 컨텐츠키 분리

Showing 2 changed files with 12 additions and 7 deletions Side-by-side Diff

insight/context.py View file @ ae1adcd
... ... @@ -56,7 +56,7 @@
56 56 time_now = int(time.time())
57 57  
58 58 return_val = []
59   - for list in self.orderlist[0:1]:
  59 + for list in self.orderlist[:1]:
60 60 time.sleep(1)
61 61 url = 'https://graph.facebook.com/v2.5/%d/feed?'%list
62 62 txt = requests.get(url + self.token).text
... ... @@ -20,10 +20,12 @@
20 20 page = Page(contexts_list)
21 21 contents_list = page.getContentsList()
22 22  
  23 + datadb = DataDB()
23 24  
24 25 for content in contents_list:
25   -
26   - id = content['id']
  26 + print content['id'].split('_')
  27 + p_id = str(content['id'].split('_')[0])
  28 + c_id = str(content['id'].split('_')[1])
27 29 created_time = content['created_time'].replace('T'," ").replace('+0000',"")
28 30 message = content['message'].replace('\n',"").replace('\r',"").replace('\'',"")
29 31  
30 32  
... ... @@ -73,12 +75,14 @@
73 75 sqlprefix = "insert into facebook_insights2 ("
74 76 sqlvalues = " values ("
75 77  
76   - sqlprefix += "`id`, "
  78 + sqlprefix += "`p_id`, "
  79 + sqlprefix += "`c_id`, "
77 80 sqlprefix += "`message`, "
78 81 sqlprefix += "`created_time`, "
79 82 sqlprefix += "`loging_time`, "
80 83  
81   - sqlvalues += "'" + id + "', "
  84 + sqlvalues += p_id + ", "
  85 + sqlvalues += c_id + ", "
82 86 sqlvalues += "'" + message + "', "
83 87 sqlvalues += "'" + created_time + "', "
84 88 sqlvalues += "NOW(), "
85 89  
... ... @@ -93,11 +97,12 @@
93 97 sqlprefix = sqlprefix[:len(sqlprefix)-2] + ")"
94 98 sqlvalues = sqlvalues[:len(sqlvalues)-2] + ");"
95 99  
96   - datadb = DataDB()
  100 +
97 101 datadb.fb_insert(sqlprefix + sqlvalues)
98 102 print sqlprefix + sqlvalues
99 103  
100 104  
101 105 del(insight)
102   - #del(datadb)
  106 +
  107 + del(datadb)