I have a text list of urls named all_urls.txt. Each url in the text file is on a single line. I want to pass this list to selenium (python) to extract specific data. I can achieve this by using the url's one by one but this is not efficient. My code at present looks like this:-
profile = FirefoxProfile('/home/test/.mozilla/firefox/mfgrtrtr.Default3')
browser = webdriver.Firefox(firefox_profile=profile)
browser.maximize_window()
# get website
browser.get('https://www.some-website.com/')
# get current url
print browser.current_url
# get name & get phone number
name = browser.find_element_by_class_name("name")
print name.text
phone = browser.find_element_by_class_name("phone")
print phone.text
How can I pass the list to browser.get and extract name and phone from each url. Thanks in advance for your help, I am new to python but enjoying the challenge.
with open(yourfile) as f:for url in map(str.rstrip, f) ...