I have a list of URIs (all of them belong to the same URL) saved in a file (about 2000).
I want to code a Python
program in order to pass these URIs one by one to Firefox using selenium
in order to check the presence of pictures on each URI (page).
Is there a way to do that safely ? I mean, if I read every URI from the file and launch firefox with it, then after checking images is done I close firefox in order to open it again with a new URI read from the file then this could crash my system/firefox at least for a while.
How can I make firefox visit all my URIs without lanching it and closing it for each new URI ?
Asked
Active
Viewed 103 times
2
1 Answers
0
Do not close the browser after visiting a link, use get()
call to load the page in the same browser session.
for link in links:
driver.get(link)
# check for presence of pictures

alecxe
- 462,703
- 120
- 1,088
- 1,195
-
the kind alecxe has answered me again. I made a short test with 2 urls and you are right: both pages are visited without firefox being closed. – Jun 24 '14 at 15:40
-
1@begueradj hope it helped. Besides, you probably want to make it faster - consider using a headless browser like `PhantomJS` instead of `Firefox`. – alecxe Jun 24 '14 at 15:42
-
1@begueradj [this answer](http://stackoverflow.com/a/15699761/771848) should help with a setup. – alecxe Jun 24 '14 at 15:43
-
On my project, I am forced to use firefox, but I may use PhantomJs for future steps in special needs. – Jun 24 '14 at 15:46
-
I kept my promise :) Thank you very much for your (former) precious help (even if this one is also important to me). Regards – Jul 01 '14 at 07:09
-
@begueradj This is really nice of you :) Thank you. – alecxe Jul 01 '14 at 13:17