2020-01-10 16:35:57 +08:00
2018-09-28 14:14:59 +08:00
2020-01-10 12:07:21 +08:00
2020-01-10 16:35:57 +08:00
2018-06-07 14:39:46 +08:00
2018-06-07 14:39:46 +08:00
2020-01-10 15:35:18 +08:00
2020-01-10 13:22:37 +08:00

DataExtracter Help


DataExtracter helps you quickly extract data from any web pages.

All you need to do is:

  • Find out the selectors for target data
  • Type scripts in the console of extension backgroud page, as introduced bellow.

Qucik Start

Extract current page

$('.item', ['a', 'a@href']);

Extract multiple pages (1-10, interval 1)

$('.item', ['a', 'a@href'],"http://sample.com/?pn=${page}", 1, 10, 1);

Extract multiple urls (list)

$('.item', ['a', 'a@href'],["http://sample.com/abc","http://sample.com/xyz"]);

Extract specified pages (1,3,5)

$('.item', ['a', 'a@href'], "http://sample.com/?pn=${page}", [1, 3, 5]);

Task Call Signitures

// extract data from current page
function (itemsSelector:string, fieldSelectors:string[])
// extract data from a range of pages
function (itemsSelector:string, fieldSelectors:string[], urlTemplate:string, from:number, to:number, interval:number)
// extract data from a list of pages
function (itemsSelector:string, fieldSelectors:string, urlTemplate:string, pages:number[])
// extract data from a list of pages
function (itemsSelector:string, fieldSelectors:string[], urls:string[])
// extract data of urls which extracted from last task result
function (itemsSelector:string, fieldSelectors:string[], urls:ExtractResult)

Advanced Usage

Stop Tasks

Tasks wait for their target elements' appearance, given some elements were loaded asynchronously.

But if you typed wrong selectors, the task waits forever for elements which don't exists.

The only way to stop tasks before its finish, is Closing the host tab.

Extract Attributes.

e.g.: link text and target (use 'selector@attribute')

new Extractor().task('.item', ['a', 'a@href']).start();

Use Task Chain.

e.g.: Collect links from http://sample.com/abc, then, Extract data of each link

new Extractor()
    .task('.search-list-item', ['a@href'], ["http://sample.com/abc"])
    .task('list-item', ["a.title", "p.content"])
    .start();

Save Result of Any Task

To a multiple task (chain) Extractor e:

e = new Extractor()
e.task('.search-list-item', ['a@href'], ["http://sample.com/abc"])
    .task('list-item', ["a.title", "p.content"])
    .start();

User will be asked to save the final result when it finishes.

Incase you want to save it again, use:

e.save()

You may want to save another task's result, other than the final:

// save the result of first task
// to the example above, that is a list of urls
e.save(1)

Restart Tasks

In cases some later task fails, you don't need to restart all task.

Here we have 2 tasks:

e = new Extractor()
e.task('.search-list-item', ['a@href'], ["http://sample.com/abc"])
    .task('list-item', ["a.title", "p.content"])
    .start();

Suppose the second task fails, we can restart and continue from the task 2:

e.restart(2);

If you'd like restart all task, use:

e.start();
// or
e.restart();
Description
No description provided
Readme 325 KiB
Languages
TypeScript 93.1%
HTML 5.1%
JavaScript 1.8%