dart_web_scraper 0.0.1 copy "dart_web_scraper: ^0.0.1" to clipboard
dart_web_scraper: ^0.0.1 copied to clipboard

An easy to use and reusable web scraper and parser.

An easy to use and reusable web scraper and parser.

Note #

This package is still in development and not ready for production use. Contributions are welcome.

Features #

This package includes 16 parsers to parse the web pages based on configuration file.

Getting started #

Import this package:

import 'package:dart_web_scraper/dart_web_scraper.dart';

Usage #

Create configuration map:

Map<String, List<Config>> configMap = {
  'quotes.toscrape.com': [
    Config(
      parsers: {
        "main": [
          Parser(
            id: "quotes",
            parent: ["_root"],
            type: ParserType.element,
            selector: [
              ".quote",
            ],
            multiple: true,
          ),
          Parser(
            id: "quote",
            parent: ["quotes"],
            type: ParserType.text,
            selector: [
              "span.text",
            ],
          ),
          Parser(
            id: "author",
            parent: ["quotes"],
            type: ParserType.text,
            selector: [
              "small.author",
            ],
          ),
        ],
      },
      urlTargets: [
        UrlTarget(
          name: 'main',
          where: [
            "/",
          ],
        ),
      ],
    ),
  ],
};

Run the scraper:

WebScraper webScraper = WebScraper();

Map<String, Object> result = await webScraper.scrape(
    url: Uri.parse("https://quotes.toscrape.com"),
    configMap: configMap,
);
8
likes
0
pub points
63%
popularity

Publisher

verified publishersukhcha.in

An easy to use and reusable web scraper and parser.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, html, http, json5, json_path, path

More

Packages that depend on dart_web_scraper