Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jesvijonathan committed Nov 3, 2021
0 parents commit acae8b4
Show file tree
Hide file tree
Showing 8 changed files with 321 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/geckodriver.log
/temp.txt
/__pycache__
37 changes: 37 additions & 0 deletions bagout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait

from config import *

import time


def bagout():

print("Bagout Test -")
driver = webdriver.Chrome("chromedriver.exe")

#bagout_link = input("Enter Product Link : ")

print("-Locating Product")
driver.get(bagout_link)

print("-Selecting Options")

try:
fsize = "//span[text()='" + str(size) + "']"
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, fsize))).click()
except Exception as e:
print(e, "!Size " + str(size) + " not available !")

print("-Adding To Cart")
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Add To Bag']"))).click()

print("-Working On It")
time.sleep(5)
print("\nDone")

return driver
113 changes: 113 additions & 0 deletions checkout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from bagout import bagout

from config import *

import time


def checkout():

driver = webdriver.Chrome("chromedriver.exe")

print("Moving to Cart..")

link = "https://www.adidas.co.in/cart"
driver.get(link)

time.sleep(3)

print("Checking Out..")

driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[2]/div[1]/div/div[3]/div/button/span").click()

checkout_pay(driver)


def checkout_pay(driver=None):

time.sleep(7)

print("-Scrolling to Bottom")

SCROLL_PAUSE_TIME = 0.5
last_height = driver.execute_script("return document.body.scrollHeight")
while True:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(SCROLL_PAUSE_TIME)
new_height = driver.execute_script("return document.body.scrollHeight")
if new_height == last_height:
break
last_height = new_height

print("-Agree to Terms")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/main/div[6]/div[1]/div/div/label/input").click()

print("-Proceeding")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/main/div[7]/button").click()

time.sleep(5)

print("-Payment")

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Cash on Delivery']"))).click()
print("-Cash On Delivery")

time.sleep(1)

# Remove the below comment to proceed placing an order | Disabled for safety purpose
#wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Place Order']"))).click()
print("-Placing Order")

print("\nDone")


def checkout_login():
print("CheckOut Test-")

driver = webdriver.Chrome("chromedriver.exe")
driver.get(bagout_link)

print("-Running Pre Bagout")
print("Just a Sec..")
try:
fsize = "//span[text()='" + str(size) + "']"
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, fsize))).click()
except Exception as e:
print(e)
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Add To Bag']"))).click()
time.sleep(5)


print("-Moving to Cart")
link = "https://www.adidas.co.in/cart"
driver.get(link)

time.sleep(3)

print("-Checking Out")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[2]/div[1]/div/div[3]/div/button/span").click()

print("-Filling In Login Details")

username = wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[2]/div/div[1]/input")))
print("-Entering Email")
username.clear()
username.send_keys(email)

pas = driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[3]/div[2]/div[1]/input")
print("-Entering Password")
pas.clear()
pas.send_keys(password)

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div/div[1]/div/div/div/div[2]/div/aside/div[1]/div/div/form/div[7]/button/span"))).click()
print("-Logging In")

time.sleep(5)

print("-Delivery Info From Account")
checkout_pay(driver)
Binary file added chromedriver.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Some features of the bot works only with www.adidas.co.in URL

# Your adidas credentials go here
email = "example@gmail.com"
password = "your_password"

# Start With Menu or Automation During StartUp
menu = 1 # 0=Menu, 1,2,..n=Automation Number | When using your own method, change it automation method number

# Automation 1 Data
early_product_lnk = "" #If you have a early product link, paste it here


# Login URL
login = "https://www.adidas.co.in/account-login" # Dont change

# Bagout & Checkout Example Data
bagout_link = "https://www.adidas.co.in/sst-aec-superearth-sw/GX3823.html" # A sample product
size = 10 # Required size

#Scrap Data
scrap_link = "https://www.adidas.co.in/originals-men-shoes" # Replace With Any Adidas Link You Want to Scrap
45 changes: 45 additions & 0 deletions login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait

from config import *

import time


def site_login():
print("LogIn Test -")

driver = webdriver.Chrome("chromedriver.exe")

print("-Opening Login Page")
driver.get(login)

print("-Entering Email")
username = wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[2]/div/div[1]/div/div/div/div[2]/div[1]/form/div[2]/div/div[1]/input")))
username.clear()
username.send_keys(email)

print("-Entering Password")
pas = driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div[1]/form/div[3]/div[2]/div[1]/input")
pas.clear()
pas.send_keys(password)

try:
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div[1]/form/div[5]/div/div/label/input").click()
print("-Remember Me Checked")
except:
pass

print("-Logging In")
driver.find_element_by_xpath("/html/body/div[2]/div/div[1]/div/div/div/div[2]/div[1]/form/div[7]/button").click()

#username.send_keys(email)
print("Loading..")

time.sleep(5)
print("\nDone")

return driver
62 changes: 62 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait

from config import *

import time

import login
import checkout
import bagout
import scrap

def load_menu():
menu_list = "\nAdidas Miner Bot v0.2\n" +\
"\n1. Login" +\
"\n2. Bagout" +\
"\n3. Checkout" +\
"\n4. Scrap" +\
"\n0. Exit\n"

while True:
sel = input(menu_list)
if sel == "1":
login.site_login()
elif sel == "2":
bagout.bagout()
elif sel == "3":
checkout.checkout_login()
elif sel == "4":
scrap.scrap()

elif sel == "5":
automation_1()

elif sel == "j":
try:
import webbrowser
webbrowser.open('https://github.com/jesvijonathan')
except:
pass

elif sel == "0":
exit(0)

def automation_1():
print("\nScript Execution 1.0")

def __main__():
if menu == 1:
load_menu()
elif menu == 0:
automation_1()





if __name__ == '__main__':
__main__()
39 changes: 39 additions & 0 deletions scrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait

from config import *

import time


def scrap():
print("Scrap Test -")

driver = webdriver.Chrome("chromedriver.exe")

print("-Opening Target Page")
driver.get(scrap_link)


print("-Loading")
time.sleep(5)

print("-Collecting")
elems = driver.find_elements_by_xpath("//a[@href]")

print("-Cleaning\n")

clean_elem = []

for elem in elems:
x = elem.get_attribute("href")

if "html" in x:
print(x)
clean_elem.append(x)

time.sleep(1)
print("\nDone")

0 comments on commit acae8b4

Please sign in to comment.