Troll & Toad: Pokemon TCG

Pokemon TCG price tracker using Python

If you want to check price down on some websites, you can use this script. I’m going to track the cost of Pokemon TCG (Reshiram & Charizard GX— 217/214— Hyper Rare Card) on this demo’s Troll & Toad page and send me an email automatically if any price drops above $50. You can use this script on all various websites.

import requests
from bs4 import BeautifulSoup
import smtplib
import time

URL="https://www.trollandtoad.com/pokemon/sun-moon-unbroken-bonds-singles/reshiram-charizard-gx-217-214-hyper-rare/1475446"
headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"}

def check_price():
	page = requests.get(URL, headers=headers)
	soup = BeautifulSoup(page.content, "html.parser")

	title = soup.find("div", {"itemprop": "name"}).get_text()
	price = soup.find("div", {"class": "font-weight-bold font-default text-center"}).get_text().replace("$", "")
	converted_price = float(price[0:5])

	if(converted_price < 249): send_mail() print(title.strip()) print(converted_price) """testing purpose""" if(converted_price > 249): 
		send_mail()

def send_mail():
	server = smtplib.SMTP("smtp.gmail.com", 587) 
	server.ehlo()
	server.starttls()
	server.ehlo()
	server.login("<your_email>", "<your_email_password")

	subject = "Price fell down!"
	body = "Check here: https://www.trollandtoad.com/pokemon/sun-moon-unbroken-bonds-singles/reshiram-charizard-gx-217-214-hyper-rare/1475446"
	msg = f"Subject: {subject}\n\n{body}"

	server.sendmail(
		"<email_from>",
		"<email_to>",
		msg
	)

	print("Email sent.")

	server.quit()

while(True):
	check_price()
	time.sleep(60)

Leave a Reply

Your email address will not be published. Required fields are marked *