I'm working with requests and beautifulsoup to parse response content of a url.
But when I try to parse the response and find the title using soup.find('title')
in Beautifulsoup, it is returning nothing to me. Not even an error.
It is simply doing nothing. the print statement above soup.find() is being executed. but not the one inside if and after if.
import requests, os
from bs4 import BeautifulSoup
lis=[
'https://oxhp-member-elr.uhc.com/Member/MemberPortal/'
]
for element in lis:
resp = requests.get(element)
if resp.status_code == 200:
cont = resp.content.decode('UTF-8')
try:
soup = BeautifulSoup(cont, "html.parser")
print('Now')
if soup.findAll('title')[0].get_text() is None:
print('Hi')
print('after if')
print(element.ljust(element_length), resp.status_code, soup.find('title').text)
except:
pass
I tried 'soup.find('title').text
also. But that didn't work either.
Can anyone let me know what's wrong with my code?
200
- Jab