0

I want to iteratively search for 30+ items through a search button in webpage and scrape the related data.

My search items are stored in a list: vol_list

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome("driver path")
driver.get("web url")
for item in vol_list :
mc_search_box = driver.find_element_by_name("search_str")
mc_search_box.clear()
search_box.send_keys(item)
search_box.send_keys(Keys.RETURN)

After search is complete I will proceed to scrape the data for each item and store in array/list. Is it possible to repeat this process without opening browser for every item in the loop?

asked Feb 24, 2017 at 18:53
1
  • 1
    See this SO answer-- especially the one by Stéphane Bruckert Commented Feb 24, 2017 at 18:59

2 Answers 2

1

You can't use chrome and other browsers without opening it.

In your case, headless browsers should do the job. Headless browsers simulates browser, but doesn't have GUI.

Try ghost driver/ html unit driver/ NodeJS. Then you will have to modify at least this line with the driver you want to use:

driver = webdriver.Chrome("driver path")

Good luck!

answered Feb 28, 2017 at 18:19

1 Comment

Thanks! I have started using PhantomJS()
0

If you're using firefox, you can apply the headless option:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
driver.get('your url')
answered Jul 9, 2022 at 7:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.