I'm currently learning Python to do some webscraping and I'm facing with an issue with If and Else
The current code is the following :
r= requests.get(urlpage, headers=headers)
soup = BeautifulSoup(r.text, 'html.parser')
div = soup.find('div', attrs={'class':'online'})
result = print(div.string)
if result == 'Online':
print('Ok')
else:
print('Next Time')
I have written print(div.string)
to get rid of div elements which is : <div class="online">Online</div>
so I get "Online" only which is working
but when I try if
and else
I always get as result "Next Time" while I'm supposed to get "Ok".
At this point i'm kinda lost, do you have any idea what's wrong ?