Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- import re
- import time
- from email.mime.text import MIMEText
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- def send(price):
- import smtplib
- msg = MIMEText("Current price is {}".format(price))
- msg['Subject'] = 'Current price'
- msg['From'] = 'piteryo7@gmail.com'
- msg['To'] = 'yury-belousov@yandex.ru'
- server = smtplib.SMTP("smtp.gmail.com:587")
- server.starttls()
- server.login('piteryo7@gmail.com', 'serg12520313')
- server.sendmail("piteryo7@gmail.com", ['yury-belousov@yandex.ru', 'piteryo7@gmail.com'], msg.as_string())
- server.quit()
- def scrape():
- dcap = dict(DesiredCapabilities.PHANTOMJS)
- dcap["phantomjs.page.settings.userAgent"] = (
- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
- "(KHTML, like Gecko) Chrome/15.0.87"
- )
- service_args = [
- '--proxy=82.137.250.78:65205',
- '--proxy-type=socks5',
- ]
- driver = webdriver.PhantomJS()
- min_price = 2000
- while True:
- driver.get("https://www.origin.com/rus/ru-ru/store/fifa/fifa-18/standard-edition")
- result = driver.execute_script("return document.documentElement.innerHTML")
- r = driver.page_source
- i = r.find('\"price\":')
- index = result.find('\"price\":')
- cur_price = re.sub("\D", "", result[index:index + 14])
- if int(cur_price) < min_price:
- send(cur_price)
- min_price = cur_price
- time.sleep(60 * 60)
- driver = webdriver.Firefox()
- driver.get("https://www.origin.com/rus/ru-ru/store/fifa/fifa-18/standard-edition")
- r = driver.execute_script('return document.body.innerHTML')
- print(r.find('\"price\":'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement