diff --git a/precos.txt b/precos.txt new file mode 100644 index 0000000..e69de29 diff --git a/webscraping.py b/webscraping.py new file mode 100644 index 0000000..778352f --- /dev/null +++ b/webscraping.py @@ -0,0 +1,15 @@ +import requests +from bs4 import BeautifulSoup + +url1 = requests.get('https://coinmarketcap.com/pt-br/currencies/bitcoin/') +#print(url1.status_code) +htmlBruto1 = url1.content + +site = BeautifulSoup(htmlBruto1, 'html.parser') +tagPreco = site.find('div', attrs={'class':'priceValue smallerPrice'}) +print(tagPreco) +preco = tagPreco.find('span') + +print() +print(preco.text) +print() \ No newline at end of file diff --git a/webscraping2.py b/webscraping2.py new file mode 100644 index 0000000..12a0c4c --- /dev/null +++ b/webscraping2.py @@ -0,0 +1,28 @@ +import requests +import schedule +import time +from bs4 import BeautifulSoup + +def job(): + url1 = requests.get('https://coinmarketcap.com/pt-br/currencies/bitcoin/') + #print(url1.status_code) + + htmlBruto1 = url1.content + site = BeautifulSoup(htmlBruto1, 'html.parser') + tagPreco = site.find('div', attrs={'class':'priceValue smallerPrice'}) + #print(tagPreco) + + preco = tagPreco.find('span') + lastPrice = " " + + while lastPrice != preco.text: + lastPrice = preco.text + with open ("precos.txt") as arquivo: + arquivo.write(lastPrice) + print(lastPrice) + +schedule.every(10).seconds.do(job) + +while True: + schedule.run_pending() + time.sleep(1) \ No newline at end of file