i'm working on a project where i'm scaping a web page. i have a problem on the condition bellow :
j=-1
for i in p:
soup_tr = BeautifulSoup(str(i) ,'html.parser')
# print(soup_tr)
cons_intitule= soup_tr.find('table',{"class":"table-results"})
nb=str(j)
print(nb)
if(soup_tr.find('span' ,{"id":"ctl0_CONTENU_PAGE_resultSearch_tableauResultSearch_ctl"+str(j)+"_reference"})):
print("enter if 1 =======================")
cons_intitule_ref= (soup_tr.find('span',{"id":"ctl0_CONTENU_PAGE_resultSearch_tableauResultSearch_ctl1_reference"})).get_text()
resultat.append(cons_intitule_ref)
//other if conditions using j too ...
j=j+1
can't access the if condition because of the variable j. what i've tested : 1)- I replaced j with a static value (1) and the condition works perfectly. but when i put j in the condition it doens't work ! 2)- also i printed the id of all iteration to check if j increments , and it perfectly does. now i really can't understand why this condition doesn't work Any Help please. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire