Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from requests_html import HTMLSession
- from bs4 import BeautifulSoup
- import time
- from datetime import datetime
- while True:
- session = HTMLSession()
- r = session.get('https://www.binance.com/ru/trade/ETH_BTC')
- r.html.render(sleep = 1, keep_page=True, scrolldown=1, timeout=100)
- soup = BeautifulSoup(r.html.html, "lxml")
- price = soup.find("div", class_ = lambda value: value and value.startswith("showPrice"))
- # with open('index.html', 'w', encoding="utf-8") as f:
- # f.write(soup.prettify())
- # f.close()
- now = datetime.now()
- dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
- print(dt_string + " ETH/BTC: " + price.text)
- time.sleep(4)
Advertisement
Add Comment
Please, Sign In to add comment