lundi 27 septembre 2021

can't get my selenium script to work on multiple links given from a list

im working on a script for my company that pulls form data as requested from the site but i can't get it to work automatically if I give the links from a list the first link is saved into a txt but i get this error message:

urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x10d715640>: Failed to establish a new connection: [Errno 61] Connection refused

And lastly here's the code i use to pull data does the site basically refuses me for using a script ? But even then when insert links one by one its fine

def getData(link):
    try:
        driver.get(link)
        header = driver.find_element_by_tag_name('h2')
        results = driver.find_elements_by_xpath("//ul[@class='firma-info']/li")
        with open('readme.txt', 'a+') as f:
            f.write(header.text + "\n")
            for result in results:
                f.write(result.text + "\n")
        driver.quit()

    except Exception as e:
        driver.quit()
        print(e)



Aucun commentaire:

Enregistrer un commentaire