Python commodity price monitoring

Original link: https://mutou.men/posts/python%E5%95%86%E5%93%81%E4%BB%B7%E6%A0%BC%E7%9B%91%E6%8E%A7 /

A simple price monitoring program written in python with the help of CHATGPT. The following functions are realized: 1. Obtain the current price 2. Reminder when the price is lower than a certain price 3. The email reminder code is as follows:
import requests from bs4 import BeautifulSoup import smtplib from email.mime.text import MIMEText from email.header import Header import time # Set your own information my_email = “[email protected]” my_password = “******” recipient_email = “[email protected]” # Commodity link and monitoring price list, fill in your desired price after target_price. Multiple product links can be added. products = [ {“url”: “https://ift.tt/r1jXuA7”, “target_price”: 800}, {“url”: “https://ift.tt/LzPnEmw”, “target_price”: 1000} ] def get_price(url): # Request product link, get web page content response = requests.get(url) soup = BeautifulSoup(response.content, “html.parser”) # Find price information and convert it to numeric type Return if “omsystem .com” in url: price_str = soup. find(“span”, {“class”: “price”}).

This article is reproduced from: https://mutou.men/posts/python%E5%95%86%E5%93%81%E4%BB%B7%E6%A0%BC%E7%9B%91%E6%8E%A7 /
This site is only for collection, and the copyright belongs to the original author.