Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Striping the empty line
#7
I am using Python 3.7.3

# pip install schedule, pendulum

from bs4 import BeautifulSoup
import requests
import schedule
import pendulum
import time


def stock():
    requestbtc = requests.get("https://bitscreener.com/coins/bitcoin")
    requesteth = requests.get("https://bitscreener.com/coins/ethereum")
    content1 = requestbtc.content
    content2 = requesteth.content
    soup1 = BeautifulSoup(content1, "html.parser")
    soup2 = BeautifulSoup(content2, "html.parser")

    element1 = soup1.find('div', {"class": "header-price-container"})
    btc = element1.text.strip().replace('\n', ' \t ')
    element2 = soup2.find('div', {"class": "header-price-container"})
    eth = element2.text.strip().replace('\n', ' \t ')
    return btc, eth


def display_prices(btc, eth):
    now = pendulum.now()
    print(f'--- {now.to_day_datetime_string()} ---')
    print("-------------BTC Price------------")
    print(btc)
    print("-------------ETH Price------------")
    print(eth)
    print('\n' * 2)

if __name__ == '__main__':
    btc, eth = stock()
    # display_prices(btc, eth)
    schedule.every(1).minutes.do(display_prices, btc=btc, eth=eth)

    while 1:
        schedule.run_pending()
        time.sleep(1)
Thanks a lot after returning btc, and eth it worked fine
Reply


Messages In This Thread
Striping the empty line - by Calli - May-23-2020, 02:49 PM
RE: Striping the empty line - by snippsat - May-23-2020, 11:41 PM
RE: Striping the empty line - by Calli - May-24-2020, 06:43 AM
RE: Striping the empty line - by snippsat - May-24-2020, 10:08 AM
RE: Striping the empty line - by Calli - May-24-2020, 02:13 PM
RE: Striping the empty line - by snippsat - May-24-2020, 02:37 PM
RE: Striping the empty line - by Calli - May-24-2020, 02:41 PM
RE: Striping the empty line - by snippsat - May-24-2020, 02:45 PM
RE: Striping the empty line - by Calli - May-24-2020, 02:47 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020