Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. from selenium import webdriver
  2. import re
  3. import time
  4. from email.mime.text import MIMEText
  5. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  6.  
  7.  
  8. def send(price):
  9. import smtplib
  10.  
  11. msg = MIMEText("Current price is {}".format(price))
  12. msg['Subject'] = 'Current price'
  13. msg['From'] = 'piteryo7@gmail.com'
  14. msg['To'] = 'yury-belousov@yandex.ru'
  15. server = smtplib.SMTP("smtp.gmail.com:587")
  16. server.starttls()
  17. server.login('piteryo7@gmail.com', 'serg12520313')
  18. server.sendmail("piteryo7@gmail.com", ['yury-belousov@yandex.ru', 'piteryo7@gmail.com'], msg.as_string())
  19. server.quit()
  20.  
  21. def scrape():
  22. dcap = dict(DesiredCapabilities.PHANTOMJS)
  23. dcap["phantomjs.page.settings.userAgent"] = (
  24. "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53 "
  25. "(KHTML, like Gecko) Chrome/15.0.87"
  26. )
  27. service_args = [
  28. '--proxy=82.137.250.78:65205',
  29. '--proxy-type=socks5',
  30. ]
  31. driver = webdriver.PhantomJS()
  32. min_price = 2000
  33. while True:
  34. driver.get("https://www.origin.com/rus/ru-ru/store/fifa/fifa-18/standard-edition")
  35.  
  36. result = driver.execute_script("return document.documentElement.innerHTML")
  37. r = driver.page_source
  38. i = r.find('\"price\":')
  39. index = result.find('\"price\":')
  40. cur_price = re.sub("\D", "", result[index:index + 14])
  41. if int(cur_price) < min_price:
  42. send(cur_price)
  43. min_price = cur_price
  44. time.sleep(60 * 60)
  45.  
  46.  
  47. driver = webdriver.Firefox()
  48. driver.get("https://www.origin.com/rus/ru-ru/store/fifa/fifa-18/standard-edition")
  49. r = driver.execute_script('return document.body.innerHTML')
  50. print(r.find('\"price\":'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement