Skip to content
FireAwayH edited this page Aug 22, 2018 · 6 revisions

Sometimes we will get some useless data unavoidably. Now we can ask Data Filter - some JavaScript code that used to process captured data in a Selector.

Useage:

Type some JS code in Data Filter and click Preview to see the result. Save the selector when you are finished.

Note:

Web Scraper Plus will generate a function and pass the captured data to it like this:

try{
    let func = new Function("data", `return ${ValueOfDataFilter}`);
    data = func(data);
}catch(e){
}

So there are 3 things need to take care:

  1. The parameter of data in Data Filter is data. It could be a string, an Array of Object or an object. Check the console log for your information.

  2. The Data Filter should return something in the end. The something must share the type of original the data.

  3. The Data Filter will be ignored if there is something wrong.

Use cases:

  1. You want to capture some numbers in a list, you can use something like RegExp to extract them.
  2. You want to match a list of items with an array, you can do some iteration.
  3. You want to transform the way of display for your final data, you can add some code in a Leaf Selector and define a Custom Columns
  4. You can even do dome Ajax requests and play with Promise if you wish, this feature is very flexiable.
Clone this wiki locally