Concatenate

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

Concatenate

Post by webmaster » Thu Apr 05, 2018 2:10 am

Sometimes a selector selects more than one element and we want to extract their concatenated values as a single value. The following function takes a separator and a sequence, and returns their concatenated values. To use this on your project, follow these instructions.

Code: Select all

function (separator sequence)
   Sequence.FirstOrDefault
      ·  Sequence.Fold
            ·  sequence
            ·  function (a b)
                  +
                     ·  a
                     ·  separator
                     ·  b
As a quick example, suppose your project contains a selector called PhoneNumbers that selects many elements on the page. Instead of just using a Select.PhoneNumbers action, which would extract the first phone number only, the following code would extract all phone numbers separated by a comma (this example also assumes you've pasted the code above into your project and called it Concatenate):

Code: Select all

Concatenate
   ·  ", "
   ·  Select.PhoneNumbers
Juan Soldi
The Helium Scraper Team

Post Reply