Only create ip card if main result div is found
The ip address card that is created for searches like "my ip" only needs to be created/inserted if a main result div id is found. Fixes #735main
parent
abc30d7da3
commit
62d7491936
|
@ -227,6 +227,8 @@ def add_ip_card(html_soup: BeautifulSoup, ip: str) -> BeautifulSoup:
|
|||
BeautifulSoup
|
||||
|
||||
"""
|
||||
main_div = html_soup.select_one('#main')
|
||||
if main_div:
|
||||
# HTML IP card tag
|
||||
ip_tag = html_soup.new_tag('div')
|
||||
ip_tag['class'] = 'ZINbbc xpd O9g5cc uUPGi'
|
||||
|
@ -246,7 +248,7 @@ def add_ip_card(html_soup: BeautifulSoup, ip: str) -> BeautifulSoup:
|
|||
ip_tag.append(ip_text)
|
||||
|
||||
# Insert the element at the top of the result list
|
||||
html_soup.select_one('#main').insert_before(ip_tag)
|
||||
main_div.insert_before(ip_tag)
|
||||
return html_soup
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue