Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import schedule
- from selenium import webdriver
- # For using sleep function because selenium
- # works only when the all the elemets of the
- # page is loaded.
- import time
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.chrome.options import Options
- import random
- array = ['https://www.zomato.com/<sample1>/network','https://www.zomato.com/<sample2>/network',
- 'https://www.zomato.com/<sample3>/network','https://www.zomato.com/<sample4>/network'
- ,'https://www.zomato.com/<sample5>/network','https://www.zomato.com/<sample6>/network','https://www.zomato.com/<sample7>/network']
- print('1')
- chrome_options = Options()
- chrome_options.add_argument('--headless')
- chrome_options.add_argument('--no-sandbox')
- chrome_options.add_argument('--disable-dev-shm-usage')
- print('2')
- browser = webdriver.Chrome(executable_path="/usr/bin/chromedriver", chrome_options=chrome_options)
- print('2a')
- def job():
- Followlink = 'https://www.zomato.com/<sample8>/network'
- browser.get(Followlink)
- browser.maximize_window()
- time.sleep(4)
- username = "yourusername"
- password = "yourpassword"
- print('3')
- # def check_exists_xpath(xpath):
- browser.find_element_by_xpath("//a[@id='signin-link']").click()
- time.sleep(3)
- browser.find_element_by_xpath("//a[@id='login-email']").click()
- time.sleep(3)
- a = browser.find_element_by_xpath("//*[@id='ld-email']")
- a.send_keys(username)
- b = browser.find_element_by_xpath("//input[@id='ld-password']")
- b.send_keys(password)
- print('4')
- browser.find_element_by_xpath("//input[@id='ld-submit-global']").click()
- time.sleep(2)
- i = 0
- checker=0
- while True:
- try:
- button = browser.find_element_by_xpath(
- "//a[@class='snippet__follow social-button follow-social zs-follow-user-button']")
- browser.execute_script("return arguments[0].scrollIntoView();", button)
- # time.sleep(1)
- button.click()
- i += 1
- ptr= random.choice([2,4,5])
- if (i == int(200/ptr)):
- browser.get(array[checker])
- checker+=1
- i=0
- print('5')
- except:
- try:
- time.sleep(2)
- k = browser.find_element_by_xpath("//div[@class='load-more']")
- browser.execute_script("return arguments[0].scrollIntoView();", button)
- time.sleep(1)
- k.click()
- print('6')
- except:
- try:
- time.sleep(2)
- k = browser.find_element_by_xpath("//div[@class='load-more']")
- browser.execute_script("return arguments[0].scrollIntoView();", button)
- time.sleep(1)
- k.click()
- print('7')
- except:
- time.sleep(3)
- k = browser.find_element_by_xpath("//div[@class='load-more']")
- browser.execute_script("return arguments[0].scrollIntoView();", button)
- time.sleep(1)
- k.click()
- print('8')
- schedule.every().wednesday.at("11:38").do(job)
- schedule.every().tuesday.at("16:15").do(job)
- schedule.every().wednesday.at("21:18").do(job)
- schedule.every().friday.at("13:21").do(job)
- schedule.every().sunday.at("11:38").do(job)
- schedule.every().tuesday.at("19:58").do(job)
- schedule.every().saturday.at("17:10").do(job)
- schedule.every().monday.at("12:43").do(job)
- schedule.every().thursday.at("23:11").do(job)
- while True:
- schedule.run_pending()
- time.sleep(1)
- browser.quit()
Add Comment
Please, Sign In to add comment