1
Good afternoon to all.
I am studying python and learning to extract data on websites and to start this learning I am creating a program that will extract the data from the lotofacil site of the savings bank and return me the values drawn in a given contest. By the examples I saw on the Internet, it is possible to search by and by or <parameter>, however, I checked that the page, the box, which has all the results by contest does not have one , IE, only have the and within a table .
I have already been able to extract the data of the entire line of a given contest, however, I am not able to process the data of the line and take only: number of the contest and numbers drawn. My code it’s showing all the values of the line.
Could someone give me a light?
import requests
from bs4 import BeautifulSoup
req = requests.get( "http://loterias.caixa.gov.br/wps/portal/loterias/landing/lotofacil/!ut/p/a1/04_Sj9CPykssy0xPLMnMz0vMAfGjzOLNDH0MPAzcDbz8vTxNDRy9_Y2NQ13CDA0sTIEKIoEKnN0dPUzMfQwMDEwsjAw8XZw8XMwtfQ0MPM2I02-AAzgaENIfrh-FqsQ9wBmoxN_FydLAGAgNTKEK8DkRrACPGwpyQyMMMj0VAcySpRM!/dl5/d5/L2dBISEvZ0FBIS9nQSEh/pw/Z7_HGK818G0K85260Q5OIRSC42046/res/id=historicoHTML/c=cacheLevelPage/=/" )
soup = BeautifulSoup( req.content, "html.parser" )
todas_linhas = soup.findAll("tr")
## LOCALIZA EM TODAS AS LINHAS 'td' O texto '2208', GUARDA DA VARIÁVEL temp ##
# A CONDIÇÃO if VERFICA NA VARIÁRIL temp E SÓ RETORNA OS VALORES QUE SÃO DIFERENTES DE None #
for tr in todas_linhas:
temp = tr.find('td', text='2208')
if temp != None:
print (tr.text)
I hope you have understood my doubt and thank you for your attention.
Would not be
print(temp.text)
?– Paulo Marques
if I print this variable temp.text.. it will only return me the value: 2208
– Douglas Almeida de Mesquita