Commit 003f69af3d45da40ebde98f17b324fa4af04c132

Authored by Noah ago
1 parent 7f1ef3a46e
Exists in master

디스크립션

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

#!/usr/bin/env python 1 1 #!/usr/bin/env python
# -*- coding: utf-8 -*- 2 2 # -*- coding: utf-8 -*-
3 3
from insight.context import Context 4 4 from insight.context import Context
from insight.token import Token 5 5 from insight.token import Token
from insight.postinsight import PostInsight 6 6 from insight.postinsight import PostInsight
from insight.datadb import DataDB 7 7 from insight.datadb import DataDB
8 8
from insight.url import Url 9 9 from insight.url import Url
import time 10 10 import time
11 11
12 12
if __name__=='__main__': 13 13 if __name__=='__main__':
14 14
token = Token() 15 15 token = Token()
16 16
contexts = Context(token) 17 17 contexts = Context(token)
contexts.setContextsFeedAndTimestemp(3600 * 24 * 10) 18 18 contexts.setContextsFeedAndTimestemp(3600 * 24 * 10)
contents_list = contexts.getContentsList() 19 19 contents_list = contexts.getContentsList()
20 20
for content in contents_list: 21 21 for content in contents_list:
datadb = DataDB() 22 22 datadb = DataDB()
time.sleep(1) 23 23 time.sleep(1)
p_id = str(content['id'].split('_')[0]) 24 24 p_id = str(content['id'].split('_')[0])
c_id = str(content['id'].split('_')[1]) 25 25 c_id = str(content['id'].split('_')[1])
26 26
insight = PostInsight(token) 27 27 insight = PostInsight(token)
insight.setContentInsight(content['id']) 28 28 insight.setContentInsight(content['id'])
29 29
created_time = insight.getContentCreated_time() 30 30 created_time = insight.getContentCreated_time()
message = insight.getContentMessage() 31 31 message = insight.getContentMessage()
message_url = Url().getText2bitly(message) 32 32 message_url = Url().getText2bitly(message)
33 33
34 34
lists =["post_story_adds_unique", 35 35 lists =["post_story_adds_unique",
"post_story_adds", 36 36 "post_story_adds",
"post_story_adds_by_action_type_unique,comment", 37 37 "post_story_adds_by_action_type_unique,comment",
"post_story_adds_by_action_type_unique,like", 38 38 "post_story_adds_by_action_type_unique,like",
"post_story_adds_by_action_type_unique,share", 39 39 "post_story_adds_by_action_type_unique,share",
"post_story_adds_by_action_type,comment", 40 40 "post_story_adds_by_action_type,comment",
"post_impressions", 41 41 "post_impressions",
"post_impressions_paid_unique", 42 42 "post_impressions_paid_unique",
"post_impressions_paid", 43 43 "post_impressions_paid",
"post_story_adds_by_action_type,like", 44 44 "post_story_adds_by_action_type,like",
"post_story_adds_by_action_type,share", 45 45 "post_story_adds_by_action_type,share",
"post_impressions_unique", 46 46 "post_impressions_unique",
"post_impressions_organic_unique", 47 47 "post_impressions_organic_unique",
"post_impressions_organic", 48 48 "post_impressions_organic",
"post_impressions_by_story_type_unique,other", 49 49 "post_impressions_by_story_type_unique,other",
"post_impressions_by_story_type,other", 50 50 "post_impressions_by_story_type,other",
"post_consumptions_by_type_unique,other clicks", 51 51 "post_consumptions_by_type_unique,other clicks",
"post_consumptions_by_type_unique,photo view", 52 52 "post_consumptions_by_type_unique,photo view",
"post_consumptions_by_type_unique,video play", 53 53 "post_consumptions_by_type_unique,video play",
"post_consumptions_by_type_unique,link clicks", 54 54 "post_consumptions_by_type_unique,link clicks",
"post_consumptions_by_type,other clicks", 55 55 "post_consumptions_by_type,other clicks",
"post_consumptions_by_type,photo view", 56 56 "post_consumptions_by_type,photo view",
"post_consumptions_by_type,video play", 57 57 "post_consumptions_by_type,video play",
"post_consumptions_by_type,link clicks", 58 58 "post_consumptions_by_type,link clicks",
"post_engaged_users", 59 59 "post_engaged_users",
"post_video_views", 60 60 "post_video_views",
"post_video_views_unique", 61 61 "post_video_views_unique",
"post_video_views_paid", 62 62 "post_video_views_paid",
"post_video_views_autoplayed", 63 63 "post_video_views_autoplayed",
"post_video_views_10s", 64 64 "post_video_views_10s",
"post_video_views_10s_unique", 65 65 "post_video_views_10s_unique",
"post_video_views_10s_paid", 66 66 "post_video_views_10s_paid",
"post_video_views_10s_organic", 67 67 "post_video_views_10s_organic",
"post_video_views_10s_clicked_to_play", 68 68 "post_video_views_10s_clicked_to_play",
"post_video_views_10s_autoplayed", 69 69 "post_video_views_10s_autoplayed",
"post_video_views_10s_sound_on", 70 70 "post_video_views_10s_sound_on",
"post_video_views_sound_on", 71 71 "post_video_views_sound_on",
"post_video_view_time", 72 72 "post_video_view_time",
"post_video_complete_views_organic", 73 73 "post_video_complete_views_organic",
"post_video_complete_views_paid"] 74 74 "post_video_complete_views_paid"]
75 75
sqlprefix = "insert into facebook_insights2 (" 76 76 sqlprefix = "insert into facebook_insights2 ("
sqlreplace = "REPLACE into facebook_insights2_last (" 77 77 sqlreplace = "REPLACE into facebook_insights2_last ("
sqlvalues = " values (" 78 78 sqlvalues = " values ("
79 79
sqlprefix += "`p_id`, " 80 80 sqlprefix += "`p_id`, "
sqlprefix += "`c_id`, " 81 81 sqlprefix += "`c_id`, "
sqlprefix += "`type`, " 82 82 sqlprefix += "`type`, "
sqlprefix += "`message`, " 83 83 sqlprefix += "`message`, "
sqlprefix += "`message_url`, " 84 84 sqlprefix += "`message_url`, "
sqlprefix += "`comment_url`, " 85 85 sqlprefix += "`comment_url`, "
sqlprefix += "`created_time`, " 86 86 sqlprefix += "`created_time`, "
sqlprefix += "`loging_time`, " 87 87 sqlprefix += "`loging_time`, "
88 88
sqlprefix += "`bit_url`, " 89 89 sqlprefix += "`bit_url`, "
sqlprefix += "`bit_click`, " 90 90 sqlprefix += "`bit_click`, "
sqlprefix += "`origin_url`, " 91 91 sqlprefix += "`origin_url`, "
sqlprefix += "`piki_cid`, " 92 92 sqlprefix += "`piki_cid`, "
sqlprefix += "`rpiki_click`, " 93 93 sqlprefix += "`rpiki_click`, "
94 94
sqlvalues += p_id + ", " 95 95 sqlvalues += p_id + ", "
sqlvalues += c_id + ", " 96 96 sqlvalues += c_id + ", "
sqlvalues += "'" + insight.getContentType() + "', " 97 97 sqlvalues += "'" + insight.getContentType() + "', "
sqlvalues += "'" + message + "', " 98 98 sqlvalues += "'" + message + "', "
sqlvalues += "'" + message_url + "', " 99 99 sqlvalues += "'" + message_url + "', "
sqlvalues += "'" + insight.getContentCommentUrl() + "', " 100 100 sqlvalues += "'" + insight.getContentCommentUrl() + "', "
sqlvalues += "'" + created_time + "', " 101 101 sqlvalues += "'" + created_time + "', "
sqlvalues += "NOW(), " 102 102 sqlvalues += "NOW(), "
103 103
url_data = Url().url2dic([insight.getLinkUrl(),message_url,insight.getContentCommentUrl()])[0] 104 104 url_data = Url().url2dic([insight.getLinkUrl(),message_url,insight.getContentCommentUrl()])[0]