Skip to content

Commit

Permalink
Added Rich Text Animations
Browse files Browse the repository at this point in the history
  • Loading branch information
saccofrancesco committed Mar 29, 2022
1 parent 09a1110 commit e403e6a
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Importing Libraries
from rich.console import Console
from rich.progress import track
from playwright.sync_api import sync_playwright
from bs4 import BeautifulSoup
import requests
Expand All @@ -14,6 +16,9 @@ class Bot:
# Constructor
def __init__(self) -> None:

# Creating a Console Instance
self.console = Console()

# Saving Items
with open("Items.json", "r") as i:
items_dict = json.load(i)
Expand Down Expand Up @@ -48,13 +53,14 @@ def __init__(self) -> None:

# Buy Times
self.HOUR = "12"
self.MINUTE = "00"
self.MINUTE = "0"

# Scrape Method for Saving the urls
def scrape(self) -> None:

# Looping the Items' Types
for i in range(len(self.items_name)):
for i in track(range(len(self.items_name)),
description="🔗 [blue]Extracting Items' Links...[/blue]"):

# Scraping
url = "https://www.supremenewyork.com/shop/all/" + \
Expand Down Expand Up @@ -83,7 +89,8 @@ def scrape(self) -> None:
def addTobasket(self, page) -> None:

# Looping the Element's to Buy List
for i in range(len(self.links_list)):
for i in track(range(len(self.links_list)),
description="💸 [green]Buying the Items...[/green]"):
page.goto(self.links_list[i])

# Saving Page Data
Expand All @@ -104,27 +111,30 @@ def addTobasket(self, page) -> None:
# Method for Compiling the Checkout Form
def checkout(self, page) -> None:

# Going to the Checkout
page.click("a.button:nth-child(3)")

# Using Data to Compile the Form
page.fill("#order_billing_name", self.name_surname)
page.fill("#order_email", self.email)
page.fill("#order_tel", self.tel)
page.fill("#order_billing_address", self.address)
page.fill("#order_billing_city", self.city)
page.fill("#order_billing_zip", str(self.postal_code))
page.click("#order_billing_country")
option = page.query_selector("#order_billing_country")
option.select_option(label=self.country.upper())
page.fill("#credit_card_number", str(self.card_number))
page.click("#credit_card_month")
option = page.query_selector("#credit_card_month")
option.select_option(label=str(self.month_exp))
page.click("#credit_card_year")
option = page.query_selector("#credit_card_year")
option.select_option(label=str(self.year_exp))
page.fill("#credit_card_verification_value", str(self.cvv))
# Performing Actions while in an Animation
with self.console.status("🖋️ [yellow]Performing the Checkout...[/yellow]"):

# Going to the Checkout
page.click("a.button:nth-child(3)")

# Using Data to Compile the Form
page.fill("#order_billing_name", self.name_surname)
page.fill("#order_email", self.email)
page.fill("#order_tel", self.tel)
page.fill("#order_billing_address", self.address)
page.fill("#order_billing_city", self.city)
page.fill("#order_billing_zip", str(self.postal_code))
page.click("#order_billing_country")
option = page.query_selector("#order_billing_country")
option.select_option(label=self.country.upper())
page.fill("#credit_card_number", str(self.card_number))
page.click("#credit_card_month")
option = page.query_selector("#credit_card_month")
option.select_option(label=str(self.month_exp))
page.click("#credit_card_year")
option = page.query_selector("#credit_card_year")
option.select_option(label=str(self.year_exp))
page.fill("#credit_card_verification_value", str(self.cvv))


# Main Program
Expand All @@ -149,7 +159,7 @@ def checkout(self, page) -> None:
with sync_playwright() as p:

# Creating a Browser Instance
browser = p.chromium.launch(headless=False)
browser = p.chromium.launch(headless=True)
page = browser.new_page()

# Adding the Requeted Elements to the Basket
Expand Down

0 comments on commit e403e6a

Please sign in to comment.