1
I’m doing a webcrawler I’m having the following problem. I had to do a separate program to print out how many candidates passed each course. Only that the last line is not running, and it would make the array of names pass to the next course of the list. The line that is not running is the last one that is written : position = position +1
The code is this
from bs4 import BeautifulSoup
import requests
import string
import re
import urllib
cursos = [
'ADMINISTRAÇÃO - GOVERNADOR VALADARES - DIURNO - SISU - GRUPO A',
'ADMINISTRAÇÃO - GOVERNADOR VALADARES - DIURNO - SISU - GRUPO B',
'ADMINISTRAÇÃO - GOVERNADOR VALADARES - DIURNO - SISU - GRUPO D',
'ADMINISTRAÇÃO - GOVERNADOR VALADARES - DIURNO - SISU - GRUPO E',
'ADMINISTRAÇÃO - JUIZ DE FORA - DIURNO - SISU - GRUPO A',
'ADMINISTRAÇÃO - JUIZ DE FORA - DIURNO - SISU - GRUPO B'
]
r = requests.get('http://www.ufjf.br/cdara/sisu-2/sisu-2017-1a-edicao/lista-de-espera-sisu-3/?id_curso=05GV&id_grupo=72')
soup = BeautifulSoup(r.text, "html.parser")
vetor = []
posicao =1
for node in soup.findAll("td"):
candidato =node.get_text("td")
vetor.append(candidato)
contador = 0
for s in vetor:
contador = contador +1
contador = int(contador/5)
contador = 5
contador2 = 0
contador2 = int(contador2)
print(contador)
while contador2<=contador:
print(cursos[posicao])
posicao = posicao +1
Didn’t my answer to your previous question help you? I asked you if you were going to do this. You don’t need to use urllib if you use requests
– Miguel
Yes it helped, I even gave it better
– SasukeUchiha
explain to me better what you want the program to do
– Miguel
I need to print out how many candidates are listed in each course. In this case I think the logic is right. The problem is last line that is not running. It should run as soon as the "while" ends, and this list of " courses" is reduced as there are many. If you open this url that is in the request you will understand a little better what I am saying. See that you have the course and how many candidates are listed there.
– SasukeUchiha
But you just want to know how many candidates there are? $150 in this case? I just don’t understand why so much code to do it, in my other answer does it, just change the url
– Miguel
not only knowing how many there are. I need to print each course as many times as have candidates listed on it. For example in this I need to print 150 times the name of the course, what would be done walking in this vector I called courses, only that the variable position is not being changed at the end of the print, to be able to pass to the next course
– SasukeUchiha
Miguel , really I was flying hard. Your other question saved everything , Very Thanks
– SasukeUchiha
You’re welcome to it
– Miguel