-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnl_mc.py
148 lines (123 loc) · 36.4 KB
/
nl_mc.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# python-mailchimp-api
# pip install mailchimp3
from mailchimp3 import MailChimp
import idx_config as conf
import json
client = MailChimp(mc_api=conf.MAILCHIMP_API_KEY, mc_user=conf.MAILCHIMP_USER)
# client = MailChimp(mc_api=MAILCHIMP_API_KEY, mc_user=MAILCHIMP_USER)
# client.campaigns.get(campaign_id='f25d3b3267')
# MASTER_MC_CAMPAIGN_ID = 'xxxxx' # master regular campaign object
# replicate existing campaign to create a new campaign
campaign = client.campaigns.actions.replicate(campaign_id=conf.MASTER_MC_CAMPAIGN_ID)
# Get campaign_id of new campaign
campaign_id = campaign.get('id')
# update content for the new campaign
# content_1 = {
# # 'plain_text': '',
# 'html':'<html>Hello Chimps!</html>',
# # 'archive_html': '<html>Hello world!</html>',
# '_links': [{
# 'rel': 'parent',
# 'href': 'https://us17.api.mailchimp.com/3.0/campaigns/f25d3b3267',
# 'method': 'GET',
# 'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Response.json'
#
# }, {
# 'rel': 'self',
# 'href': 'https://us17.api.mailchimp.com/3.0/campaigns/f25d3b3267/content',
# 'method': 'GET',
# 'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Content/Response.json'
#
# }, {
# 'rel': 'create',
# 'href': 'https://us17.api.mailchimp.com/3.0/campaigns/f25d3b3267/content',
# 'method': 'PUT',
# 'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Content/PUT.json'
# }]
# }
# load records from file to json object
json_mt101_data = json.load(open('mt101_data.txt'))
# prep html file, mobile optimized
# html_data = '<html> Title: '+json_mt101_data[0]['title']+\
# '<br/>'\
# +'Author: '+json_mt101_data[0]['author']+'</html>'
html_data='<html><head><meta property=\"og:title\" content=\"MARTECH101 - Top Sold and Read Marketing Books Weekly\">' \
'<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\">' \
'<meta name=\"referrer\" content=\"origin\"> ' \
'<!--[if gte mso 15]> <xml> <o:OfficeDocumentSettings> <o:AllowPNG/> <o:PixelsPerInch>96</o:PixelsPerInch> ' \
'</o:OfficeDocumentSettings> </xml> <![endif]--><meta charset=\"UTF-8\">' \
'<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">' \
'<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">' \
'<title>Martech Weekly - Most Sold and Read Marketing Books Weekly</title>' \
'<style type=\"text/css\">html{font-weight:300}' \
'p{margin:10px 0;padding:0}table{border-collapse:collapse}' \
'h1,h2,h3,h4,h5,h6{display:block;margin:0;padding:0;font-weight:300 !important}' \
'a{font-weight:300 !important;color:#107896 !important;text-decoration:none !important}' \
'a.title-link{color:#0c596e !important;font-size:1.1rem !important}' \
'h3.title{font-size:16px !important;line-height:1.5 !important}' \
'img,a img{border:0;height:auto;outline:none;text-decoration:none}' \
'body,#bodyTable,#bodyCell{height:100%;margin:0;padding:0;width:100%}' \
'#outlook a{padding:0}img{-ms-interpolation-mode:bicubic}table{mso-table-lspace:0pt;mso-table-rspace:0pt}' \
'.ReadMsgBody{width:100%}.ExternalClass{width:100%}p,a,li,td,blockquote{mso-line-height-rule:exactly}' \
'a[href^=tel],a[href^=sms]{color:inherit;cursor:default;text-decoration:none}' \
'p,a,li,td,body,table,blockquote{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}' \
'.ExternalClass,.ExternalClass p,.ExternalClass td,.ExternalClass div,.ExternalClass span,.ExternalClass font{line-height:100%}a[x-apple-data-detectors]{color:inherit !important;text-decoration:none !important;font-size:inherit !important;font-family:inherit !important;font-weight:inherit !important;line-height:inherit !important}#bodyCell{padding:10px}.templateContainer{max-width:600px !important}a.mcnButton{display:block}.mcnImage{vertical-align:bottom}.mcnTextContent{word-break:break-word}' \
'.mcnTextContent img{height:auto !important}.mcnDividerBlock{table-layout:fixed !important}' \
'body,#bodyTable{background-color:white}#bodyCell{border-top:0}.templateContainer{border:0}' \
'h1{color:#202020;font-family:Helvetica;font-size:26px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left}' \
'h2{color:#202020;font-family:Helvetica;font-size:22px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left}' \
'h3{color:#202020;font-family:Helvetica;font-size:20px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left}' \
'h4{color:#202020;font-family:Helvetica;font-size:18px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left}' \
'#templatePreheader{background-color:white;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px}' \
'#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:left}' \
'#templatePreheader .mcnTextContent a,#templatePreheader .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline}' \
'#templateHeader{background-color:#FFF;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:0}' \
'#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{color:#202020;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left}' \
'#templateHeader .mcnTextContent a,#templateHeader .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline}' \
'#templateBody{background-color:#FFF;border-top:0;border-bottom:2px solid #EAEAEA;padding-top:0;padding-bottom:9px}' \
'#templateBody .mcnTextContent,#templateBody .mcnTextContent p{color:#202020;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left}' \
'#templateBody .mcnTextContent a,#templateBody .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline}' \
'#templateFooter{background-color:white;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px}' \
'#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:center}#templateFooter .mcnTextContent a,#templateFooter .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline}@media only screen and (min-width:768px){.templateContainer{width:600px !important}}@media only screen and (max-width: 480px){body,table,td,p,a,li,blockquote{-webkit-text-size-adjust:none !important}}@media only screen and (max-width: 480px){body{width:100% !important;min-width:100% !important}}@media only screen and (max-width: 480px){#bodyCell{padding-top:10px !important}}@media only screen and (max-width: 480px){.mcnImage{width:100% !important}}@media only screen and (max-width: 480px){.mcnCartContainer,.mcnCaptionTopContent,.mcnRecContentContainer,.mcnCaptionBottomContent,.mcnTextContentContainer,.mcnBoxedTextContentContainer,.mcnImageGroupContentContainer,.mcnCaptionLeftTextContentContainer,.mcnCaptionRightTextContentContainer,.mcnCaptionLeftImageContentContainer,.mcnCaptionRightImageContentContainer,.mcnImageCardLeftTextContentContainer,.mcnImageCardRightTextContentContainer{max-width:100% !important;width:100% !important}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer{min-width:100% !important}}@media only screen and (max-width: 480px){.mcnImageGroupContent{padding:9px !important}}@media only screen and (max-width: 480px){.mcnCaptionLeftContentOuter .mcnTextContent,.mcnCaptionRightContentOuter .mcnTextContent{padding-top:9px !important}}@media only screen and (max-width: 480px){.mcnImageCardTopImageContent,.mcnCaptionBlockInner .mcnCaptionTopContent:last-child .mcnTextContent{padding-top:18px !important}}@media only screen and (max-width: 480px){.mcnImageCardBottomImageContent{padding-bottom:9px !important}}@media only screen and (max-width: 480px){.mcnImageGroupBlockInner{padding-top:0 !important;padding-bottom:0 !important}}@media only screen and (max-width: 480px){.mcnImageGroupBlockOuter{padding-top:9px !important;padding-bottom:9px !important}}@media only screen and (max-width: 480px){.mcnTextContent,.mcnBoxedTextContentColumn{padding-right:18px !important;padding-left:18px !important}}@media only screen and (max-width: 480px){.mcnImageCardLeftImageContent,.mcnImageCardRightImageContent{padding-right:18px !important;padding-bottom:0 !important;padding-left:18px !important}}@media only screen and (max-width: 480px){.mcpreview-image-uploader{display:none !important;width:100% !important}}@media only screen and (max-width: 480px){h1{font-size:22px !important;line-height:125% !important}}@media only screen and (max-width: 480px){h2{font-size:20px !important;line-height:125% !important}}@media only screen and (max-width: 480px){h3{font-size:18px !important;line-height:125% !important}}@media only screen and (max-width: 480px){h4{font-size:16px !important;line-height:150% !important}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer .mcnTextContent,.mcnBoxedTextContentContainer .mcnTextContent p{font-size:14px !important;line-height:150% !important}}@media only screen and (max-width: 480px){#templatePreheader{display:block !important}}@media only screen and (max-width: 480px){#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{font-size:14px !important;line-height:150% !important}}@media only screen and (max-width: 480px){#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{font-size:16px !important;line-height:150% !important}}@media only screen and (max-width: 480px){#templateBody .mcnTextContent,#templateBody .mcnTextContent p{font-size:16px !important;line-height:150% !important}}@media only screen and (max-width: 480px){#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{font-size:14px !important;line-height:150% !important}}</style></head><body id=\"archivebody\" style=\"height: 100%;margin: 0;padding: 0;width: 100%;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: white;\"><center><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width: 100%;min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\" width=\"100%\" class=\"mcnTextContentContainer\"><tbody><tr><td valign=\"top\" class=\"mcnTextContent\" style=\"padding-top: 0;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;\"><h1 style=\"font-weight: bold;display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 26px;font-style: normal;line-height: 125%;letter-spacing: normal;text-align: left;\"><span><a href=\"http://www.martech101.com\" style=\"text-decoration: none;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #107896 !important;font-weight: 300 !important;\">Your weekly fix of top marketing books.</a></span></h1><div style=\"margin-top: 40px;\"><table style=\"border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><tbody><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[0]['detail_page_url']+'\"><img src=\"'+json_mt101_data[0]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[0]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">1. '+json_mt101_data[0]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[1]['detail_page_url']+'\"><img src=\"'+json_mt101_data[1]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[1]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">2. '+json_mt101_data[1]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[2]['detail_page_url']+'\"><img src=\"'+json_mt101_data[2]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[2]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">3. '+json_mt101_data[2]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[3]['detail_page_url']+'\"><img src=\"'+json_mt101_data[3]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[3]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">4. '+json_mt101_data[3]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[4]['detail_page_url']+'\"><img src=\"'+json_mt101_data[4]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[4]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">5. '+json_mt101_data[4]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[5]['detail_page_url']+'\"><img src=\"'+json_mt101_data[5]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[5]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">6. '+json_mt101_data[5]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[6]['detail_page_url']+'\"><img src=\"'+json_mt101_data[6]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[6]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">7. '+json_mt101_data[6]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[7]['detail_page_url']+'\"><img src=\"'+json_mt101_data[7]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[7]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">8. '+json_mt101_data[7]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[8]['detail_page_url']+'\"><img src=\"'+json_mt101_data[8]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[8]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">9. '+json_mt101_data[8]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[9]['detail_page_url']+'\"><img src=\"'+json_mt101_data[9]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[9]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">10. '+json_mt101_data[9]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[10]['detail_page_url']+'\"><img src=\"'+json_mt101_data[10]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[10]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">11. '+json_mt101_data[10]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[11]['detail_page_url']+'\"><img src=\"'+json_mt101_data[11]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[11]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">12. '+json_mt101_data[11]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[12]['detail_page_url']+'\"><img src=\"'+json_mt101_data[12]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[12]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">13. '+json_mt101_data[12]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[13]['detail_page_url']+'\"><img src=\"'+json_mt101_data[13]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[13]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">14. '+json_mt101_data[13]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[14]['detail_page_url']+'\"><img src=\"'+json_mt101_data[14]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[14]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">15. '+json_mt101_data[14]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[15]['detail_page_url']+'\"><img src=\"'+json_mt101_data[15]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[15]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">16. '+json_mt101_data[15]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[16]['detail_page_url']+'\"><img src=\"'+json_mt101_data[16]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[16]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">17. '+json_mt101_data[16]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[17]['detail_page_url']+'\"><img src=\"'+json_mt101_data[17]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[17]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">18. '+json_mt101_data[17]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[18]['detail_page_url']+'\"><img src=\"'+json_mt101_data[18]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[18]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">19. '+json_mt101_data[18]['title']+'</a></h3></td></tr><tr><td style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><div style=\"height: 100px; width: 80px; padding-right: 15px;\"><a href=\"'+json_mt101_data[19]['detail_page_url']+'\"><img src=\"'+json_mt101_data[19]['large_image_url']+'\" style=\"max-height: 100px;max-width: 80px;border: 0;height: auto !important;outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;\"></a></div></td><td style=\"padding-top: 20px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;\"><h3 class=\"title\" style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 16px !important;font-style: normal;font-weight: 300 !important;line-height: 1.5 !important;letter-spacing: normal;text-align: left;\"><a class=\"title-link\" href=\"'+json_mt101_data[19]['detail_page_url']+'\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #0c596e !important;font-weight: 300 !important;text-decoration: none !important;font-size: 1.1rem !important;\">20. '+json_mt101_data[19]['title']+'</a></h3></td></tr></tbody></table><br><p style=\"margin: 10px 0;padding: 0;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #202020;font-family: Helvetica;font-size: 16px;line-height: 150%;text-align: left;\"></p><h3 style=\"display: block;margin: 0;padding: 0;color: #202020;font-family: Helvetica;font-size: 20px;font-style: normal;font-weight: 300 !important;line-height: 125%;letter-spacing: normal;text-align: left;\"> <a href=\"http://www.martech101.com\" style=\"mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;color: #107896 !important;font-weight: 300 !important;text-decoration: none !important;\">See more top selling and read marketing books on Martech101...</a></h3><p></p></div></td></tr></tbody></table></center></body></html>'
# def htmlfiletostr(file):
# '''
# method reads a html file and returns a str
# :return: str
# '''
# str = ""
# with open(file) as report_file:
# raw_html = report_file.readlines()
# str = ''.join(raw_html)
# return str
#
# set dyn_html_content
# dyn_html_content = htmlfiletostr("nl_sample.htm")
dyn_html_content = html_data
dyn_content = {
# 'plain_text': '',
'html': dyn_html_content,
# 'archive_html': '<html>Hello world!</html>',
'_links': [{
'rel': 'parent',
'href': 'https://us17.api.mailchimp.com/3.0/campaigns/'+campaign_id,
'method': 'GET',
'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Response.json'
}, {
'rel': 'self',
'href': 'https://us17.api.mailchimp.com/3.0/campaigns/'+campaign_id+'/content',
'method': 'GET',
'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Content/Response.json'
}, {
'rel': 'create',
'href': 'https://us17.api.mailchimp.com/3.0/campaigns/'+campaign_id+'/content',
'method': 'PUT',
'targetSchema': 'https://us17.api.mailchimp.com/schema/3.0/Definitions/Campaigns/Content/PUT.json'
}]
}
# print(json.dumps(dyn_content))
# update content of the new campaign_id
client.campaigns.content.update(campaign_id=campaign_id, data=dyn_content)
# send the latest campaign_id
client.campaigns.actions.send(campaign_id=campaign_id)
# remove old campaign id
# TDB