Skip to content

Commit

Permalink
Não esquecer dde terminar o webscraping !!
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-cavano committed Apr 26, 2022
1 parent f073aae commit 2f4e581
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Empty file added precos.txt
Empty file.
15 changes: 15 additions & 0 deletions webscraping.py
Original file line number Diff line number Diff line change
@@ -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()
28 changes: 28 additions & 0 deletions webscraping2.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 2f4e581

Please sign in to comment.