1

I am web scraping amazon and trying to send an email to a recipient every time the the lowest price of a list products changes. My code is the following. j is a dictionary of {title:price}. title_rating is a dictiionary of {title:rating} and so on.

def create_message():
    message = f""
    for title in j:
        #print(title)
        cr_price = j[title]
        cr_rating = title_rating[title]
        cr_reviews = title_num_reviews[title]
        cr_avail = title_avail[title]
        str1 = f"Product Title = {title}\n"
        str2 = f"{str1}Product Price = {cr_price}\n"
        str3 = f"{str2}Product Rating = {cr_rating}\n"
        str4 = f"{str3}Number of Product Reviews = {cr_reviews}\n"
        str5 = f"{str4}Availability = {cr_avail}\n\n"
        message += str5 #str1 + str2 + str3 + str4 + str5
    print("message sent")

    return message 
def send_email(message, sender_email, sender_password, receiver_email):
    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.starttls()
    s.login(sender_email, sender_password)
    s.sendmail(sender_email, receiver_email, message)
    s.quit()

I get the following message. Gmail Error Message

JackLalane1
  • 177
  • 10

1 Answers1

1

I found that the \u2013 is a hyphen and decided to tell the message to ignore it with

message = message.replace("\u2013", " ")
JackLalane1
  • 177
  • 10