Skip to content

Gonzih/crabquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 1, 2022
5d2cf96 · Apr 1, 2022

History

54 Commits
Jan 3, 2022
Jul 12, 2020
Dec 28, 2020
Feb 20, 2020
Apr 1, 2022
Apr 1, 2022
Feb 21, 2020
Jan 3, 2022
Feb 24, 2020
Feb 21, 2020

Repository files navigation

CrabQuery - like JQuery, but for Crabs

CI Crates.io docs.rs MIT licensed

Small and simple library to query HTML markup for your web scraping needs.

Based on servo libraries. Supports more complicated CSS selectors than other similar libraries.

Examples

use crabquery::Document;

let doc = Document::from(
    "<div class='container'>
       <a class='link button' id='linkmain'>
         <span>text hi there</span>
       </a>
     </div>",
);

let sel = doc.select("div.container > a.button.link[id=\"linkmain\"]");
let el = sel.first().unwrap();

assert_eq!(el.attr("id").unwrap(), "linkmain");

let sel = doc.select("div > a > span");
let el = sel.first().unwrap();

assert_eq!(el.text().unwrap(), "text hi there");