Hello guys,
I'm building a web scraper and everything went smooth so far until I came across such situation:
There is a <p> tag that contains the information that I need to pick.
<p>
<strong>Travel date:</strong> 2019.10.10<br>
<strong>Travel duration:</strong> 7 nights
</p>
The problem is that I need to pick the date (2019.10.10) and the number of nights (7 nights) only.
AttributeError: 'NoneType' object has no attribute 'next_sibling'
I've added a line to check if the variable is None and find another info.
I'm building a web scraper and everything went smooth so far until I came across such situation:
There is a <p> tag that contains the information that I need to pick.
<p>
<strong>Travel date:</strong> 2019.10.10<br>
<strong>Travel duration:</strong> 7 nights
</p>
The problem is that I need to pick the date (2019.10.10) and the number of nights (7 nights) only.
travel_date = inner_page_soup.find('strong', text='Travel date:').next_siblingIt works until there is no such "sibling" and I get such error:
AttributeError: 'NoneType' object has no attribute 'next_sibling'
I've added a line to check if the variable is None and find another info.
if travel_date is None: travel_date = inner_page_soup.find('div', {"class":"info"}).span.textDo you have any ideas why it's not working?