CRutkowski/Kijiji-Scraper

[Error] Unable to create body for email message

Closed this issue · 2 comments

[Error] Unable to create body for email message
Traceback (most recent call last):
File "kijiji.py", line 250, in
main()
File "kijiji.py", line 247, in main
scrape(url_to_scrape, old_ad_dict, exclude_list, filename, skip_flag)
File "kijiji.py", line 198, in scrape
MailAd(ad_dict, email_title) # Send out email with new ads
File "kijiji.py", line 132, in MailAd
msg = MIMEText(body, 'html')
File "/usr/lib/python2.7/email/mime/text.py", line 30, in init
self.set_payload(_text, _charset)
File "/usr/lib/python2.7/email/message.py", line 226, in set_payload
self.set_charset(charset)
File "/usr/lib/python2.7/email/message.py", line 262, in set_charset
self._payload = self._payload.encode(charset.output_charset)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 451: ordinal not in range(128)

Are you using python 2.7 to run the script? Use python 3 if you are and see if the error still persists.

Yes, I was using 2.7. I used version 3 and the script is working as expected. Thank you.