diff --git a/app/routes.py b/app/routes.py index d3d92ab..ba8dc02 100644 --- a/app/routes.py +++ b/app/routes.py @@ -253,34 +253,36 @@ def search(): resp_code = 503 if has_captcha(str(response)) else 200 # Feature to display IP address - html_soup = bsoup(response,'html.parser') - if not html_soup.select_one(".EY24We") and html_soup.select_one(".OXXup").get_text().lower()=="all": - if re.search("([^a-z0-9]|^)my *[^a-z0-9] *(ip|internet protocol)(\Z|( *[^a-z0-9] *(((addres|address|adres|adress)|a)? *\Z)))",query.lower()): + html_soup = bsoup(response, 'html.parser') + if(not html_soup.select_one(".EY24We") + and html_soup.select_one(".OXXup").get_text().lower() == "all"): + if re.search("([^a-z0-9]|^)my *[^a-z0-9] *(ip|internet protocol)" + + "($|( *[^a-z0-9] *(((addres|address|adres|adress)|a)? *$)))", query.lower()): # HTML IP card tag ip_tag = html_soup.new_tag("div") - ip_tag["class"]="ZINbbc xpd O9g5cc uUPGi" + ip_tag["class"] = "ZINbbc xpd O9g5cc uUPGi" # What is my IP tag q_tag=html_soup.new_tag("div") - q_tag["class"]="kCrYT" - q_tag.string="What's my IP" + q_tag["class"] = "kCrYT" + q_tag.string = "What's my IP" # Distinction boundary line = html_soup.new_tag("div") - line["class"]="x54gtf" + line["class"] = "x54gtf" # For IP Address html tag ip_address = html_soup.new_tag("div") - ip_address["class"]="kCrYT" - ip_address["style"]="padding-bottom:0;" - ip_address.string= request.remote_addr + ip_address["class"] = "kCrYT" + ip_address["style"] = "padding-bottom:0;" + ip_address.string = request.remote_addr # Text below the IP address ip_text = html_soup.new_tag("div") - ip_text.string="Your public IP address" - ip_text["class"]="kCrYT" - ip_text["style"]="padding-top:0; color: #9e9e9e!important;" + ip_text.string = "Your public IP address" + ip_text["class"] = "kCrYT" + ip_text["style"] = "padding-top: 0; color: #9e9e9e!important;" # Adding all the above html tags to the IP card ip_tag.append(q_tag) @@ -290,7 +292,7 @@ def search(): # Finding the element before which the IP card would be placed first_link_in_results = html_soup.select_one(".BNeawe.vvjwJb.AP7Wnd") - ref_element = first_link_in_results.find_parent(class_="ZINbbc xpd O9g5cc uUPGi") + ref_element = first_link_in_results.find_parent(class_ = "ZINbbc xpd O9g5cc uUPGi") # Inserting the element ref_element.insert_before(ip_tag)