forked from martinsbalodis/web-scraper-chrome-extension
-
Notifications
You must be signed in to change notification settings - Fork 18
Data Filter
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
.
Type some JS code in Data Filter and click Preview to see the result. Save the selector when you are finished.
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:
-
The parameter of data in Data Filter is
data
. It could be astring
, anArray
ofObject
or anobject
. Check the console log for your information. -
The Data Filter should return
something
in the end. Thesomething
must share the type of original thedata
. -
The Data Filter will be ignored if there is something wrong.
- You want to capture some numbers in a list, you can use something like
RegExp
to extract them. - You want to match a list of items with an array, you can do some iteration.
- 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
- You can even do dome Ajax requests and play with
Promise
if you wish, this feature is very flexiable.