D
D
Drayvod2018-04-19 23:50:13
Python
Drayvod, 2018-04-19 23:50:13

Line by line following links from a list through a for loop?

Hi, I can't figure out how to implement this.
In my "spis" list, links to sites are loaded line by line.
Next, you need to execute the "Brouser,get()" action on each link from the list.
But I can't figure out how to do this, because I create the "get" variable before the loop and I can't add the list to it.
Thank you in advance.

from selenium import webdriver
from selenium.webdriver import Firefox

browser = webdriver.Firefox()

spis = []
with open('file.txt') as f:
    spis = f.read().splitlines()

get = browser.get(spis)



for get in xrange(1,10):
  pass

5ad90075d2539141025625.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly, 2018-04-20
@trofimovdev

I think you're over complicating things...

from selenium import webdriver
from selenium.webdriver import Firefox

browser = webdriver.Firefox()

with open('file.txt') as f:
    browser.get(f.readline())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question