Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import urllib
- import lxml.html
- import time
- import datetime
- from crontab import CronTab
- from bs4 import BeautifulSoup
- from selenium import webdriver
- from selenium.webdriver.support.ui import WebDriverWait
- while True:
- # Enter the APKMirror URL you'd like to check for changes
- url = "https://www.apkmirror.com/apk/google-inc/gmail"
- headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
- response = requests.get(url, headers=headers)
- soup = BeautifulSoup(response.text, "lxml")
- # get the current date
- currentTime = '{dt:%B} {dt.day}, {dt.year}'.format(dt=datetime.datetime.now())
- if str(soup).find(currentTime) == -1:
- print('Nothing to see here. (' + currentTime + ' at ' + '{dt:%I}:{dt:%M}'.format(dt=datetime.datetime.now()) + ')')
- time.sleep(60)
- continue
- # if there's a new APK, navigate to the download page and grab it
- else:
- driver = webdriver.Chrome(executable_path="D:/Users/kylew/Anaconda3/selenium/webdriver/chromedriver/chromedriver.exe")
- driver.get(url)
- WebDriverWait(driver, 10)
- apkMainPage = driver.find_element_by_xpath("//*[@id=\"primary\"]/div[4]/div[2]/div/div[4]/div/div[2]/a")
- apkMainPage.click()
- WebDriverWait(driver, 10)
- apkDownloadPage = driver.find_element_by_xpath("//*[@id=\"file\"]/div[1]/div[2]/div/a")
- apkDownloadPage.click()
- time.sleep(60)
- driver.close()
- print('Latest APK downloaded. (' + currentTime + ' at ' + '{dt:%I}:{dt:%M}'.format(dt=datetime.datetime.now()) + ')')
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement