I am very new to Python. I am trying to write a program that will take an IP address and use the search function on https://community.spiceworks.com/tools/ip-lookup/ to search that IP and return the results to me.
I wrote this:
import selenium.webdriver as webdriver
def get_results(search_term):
url = "https://community.spiceworks.com/tools/ip-lookup/"
browser = webdriver.Firefox()
browser.get(url)
search_box = browser.find_element_by_id("ipaddress")
search_box.send_keys(search_term)
search_box.submit()
try:
tables = browser.find_element_by_class("in-card detail-list ember-view")
results = []
for table in tables:
print(table)
results.append(table)
browser.close()
return results
print(results)
get_results("137.2.167.117")
(I used a random IP address) When I run this, I get:
results = [] (with an arrow pointing to the "s" in results) SyntaxError: invalid syntax
Am I writing this code correctly? What is causing that error? And am I using the search function and results correctly? Searching this didn't return many results. Thanks!