Select Each Option

Premades & Resources to be used with Helium Scraper 3
Post Reply
webmaster
Site Admin
Posts: 444
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Select Each Option

Post by webmaster » Sat Mar 31, 2018 11:00 pm

The following code selects each option in a drop down menu. Must occur below a selector that selects the drop down element. To use this code, see how to copy/paste code into Helium Scraper 3.

Code: Select all

Browser.EvalScript
   ·  "return Array.from(element.querySelectorAll('option')).map(a => a.value)"
   ·  0
as value
Browser.InputValue
   ·  value
To skip options from the top, use the Sequence.Skip function as in the following example (this example assumes the project already contains a selector called DropDown that selects the menu element, and the code above was pasted under a global called SelectEach):

Code: Select all

Select.DropDown
Sequence.Skip
   ·  1
   ·  SelectEach
An additional requirement may be to extract the text of the currently selected item. This can be achieved with the drop down selector, followed by a CSS selector that selects the selected option:

Code: Select all

Select.DropDown
SelectBy.Css
   ·  "option:checked"
Juan Soldi
The Helium Scraper Team

webmaster
Site Admin
Posts: 444
Joined: Mon Dec 06, 2010 8:39 am
Contact:

Re: Select Each Option

Post by webmaster » Tue Sep 11, 2018 6:45 pm

MariJar wrote:
Mon Aug 27, 2018 2:38 pm
I have this select option that I attached some hyperlink to and java script code/function but it does not work
HTML Code:
Can't see the HTML code. Can you post the actual URL?
Juan Soldi
The Helium Scraper Team

Post Reply