| Line 6... |
Line 6... |
| 6 |
from email.mime.multipart import MIMEMultipart
|
6 |
from email.mime.multipart import MIMEMultipart
|
| 7 |
import json
|
7 |
import json
|
| 8 |
import chardet
|
8 |
import chardet
|
| 9 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
9 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
| 10 |
from shop2020.utils import EmailAttachmentSender
|
10 |
from shop2020.utils import EmailAttachmentSender
|
| - |
|
11 |
import re
|
| 11 |
|
12 |
|
| 12 |
|
13 |
|
| 13 |
headers = {
|
14 |
headers = {
|
| 14 |
'Browser-Name': 'Chrome',
|
15 |
'Browser-Name': 'Chrome',
|
| 15 |
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; A0001 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.121 Mobile Safari/537.36 FKUA/Retail/550900/Android/Mobile (OnePlus/A0001)',
|
16 |
'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; A0001 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.121 Mobile Safari/537.36 FKUA/Retail/550900/Android/Mobile (OnePlus/A0001)',
|
| Line 113... |
Line 114... |
| 113 |
<td style="text-align:center">"""+(CATEGORY_MAP.get(item.category))+"""</td>
|
114 |
<td style="text-align:center">"""+(CATEGORY_MAP.get(item.category))+"""</td>
|
| 114 |
<td style="text-align:center">"""+str(item.rank)+"""</td>
|
115 |
<td style="text-align:center">"""+str(item.rank)+"""</td>
|
| 115 |
<td style="text-align:center">"""+(item.url)+"""</td>
|
116 |
<td style="text-align:center">"""+(item.url)+"""</td>
|
| 116 |
</tr>"""
|
117 |
</tr>"""
|
| 117 |
message+="""</tbody></table></body></html>"""
|
118 |
message+="""</tbody></table></body></html>"""
|
| 118 |
message = message.decode('ascii', 'ignore')
|
119 |
message = sanitizeUnicode(message)
|
| - |
|
120 |
print message
|
| 119 |
#recipients = ['kshitij.sood@saholic.com']
|
121 |
#recipients = ['kshitij.sood@saholic.com']
|
| 120 |
recipients = ['kshitij.sood@saholic.com','ritesh.chauhan@saholic.com','aishwarya.singh@saholic.com']
|
122 |
recipients = ['amit.gupta@shop2020.in']
|
| 121 |
EmailAttachmentSender.mail_send_grid("dtr@profitmandi.com","apikey", "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", recipients, "Flipkart Best Sellers",message ,[],[],[])
|
123 |
EmailAttachmentSender.mail_send_grid("dtr@profitmandi.com","apikey", "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", recipients, "Flipkart Best Sellers",message ,[],[],[])
|
| 122 |
|
124 |
|
| 123 |
|
125 |
|
| - |
|
126 |
def sanitizeUnicode(unicodeText):
|
| - |
|
127 |
#remove unicode characters
|
| - |
|
128 |
unicodeText = re.sub(r'[^\x00-\x7F]+','', unicodeText)
|
| - |
|
129 |
#remove whitespaces and strip
|
| - |
|
130 |
unicodeText = re.sub(r'[^\S]+',' ', unicodeText)
|
| - |
|
131 |
return unicodeText.strip().encode('utf-8', 'ignore')
|
| - |
|
132 |
|
| 124 |
def main():
|
133 |
def main():
|
| 125 |
scrapeBestSellerMobiles()
|
134 |
scrapeBestSellerMobiles()
|
| 126 |
resetRanks(3)
|
135 |
resetRanks(3)
|
| 127 |
scrapeBestSellerTablets()
|
136 |
scrapeBestSellerTablets()
|
| 128 |
resetRanks(5)
|
137 |
resetRanks(5)
|