Giter Site home page Giter Site logo

importcjj / nipper Goto Github PK

View Code? Open in Web Editor NEW
121.0 6.0 18.0 4.29 MB

A Rust crate for manipulating HTML with CSS selectors

Home Page: https://docs.rs/nipper

License: Apache License 2.0

Rust 100.00%
css-selectors scraper html spider html5ever nipper selectors

nipper's Introduction

Nipper

A crate for manipulating HTML with Rust.

Nipper based on HTML crate html5ever and the CSS selector crate selectors. You can use the jQuery-like syntax to query and manipulate an HTML document quickly. Not only can query, but also can modify.

nipper-logo

Example

Extract the hacker news.

use nipper::Document;

fn main() {
    let html = include_str!("../test-pages/hacker_news.html");
    let document = Document::from(html);

    document.select("tr.athing").iter().for_each(|athing| {
        let title = athing.select(".title a");
        let href = athing.select(".storylink");
        println!("{}", title.text());
        println!("{}", href.attr("href").unwrap());
        println!();
    });
}

Readability.

examples/readability.rs

Related projects

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

nipper's People

Contributors

atul9 avatar importcjj avatar thedodd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nipper's Issues

Thank you!

I just wanted to say thank you for putting this project together. I looked through crates.io & lib.rs for a fair amount of time, and I knew there had to be a project out there that just worked, and had a mutation interface. And you have a CSS selector based interface. Doesn't get better than this!

Feel free to close this issue once you're sick of looking at it :).

0.1.9 release

Hey there. Anything in particular blocking the 0.1.9 release? I recently forked the project to add a few needed methods, then I found that the methods already exist as of 0.1.9, but have not yet been released.

Just wanted to touch base and see if there is any particular reason for this, or if it is just due to timing (which I totally understand).

Cheers

Question on creating new nodes

Hi, I haven't looked at this project too deeply so excuse me if this question sounds ignorant. Is it possible to make a new Node and is it possible to make it from an HTML string?

Fix `append_with_selection`

Function append_with_selection will cause panic when the given selection object comes from another dom tree.

Add an ID field to every dom tree.

Unicode miss conversion ?

image

What's happen?

let html_document = Document::from(data.as_str());

    let price = match html_document
        .select(product_data.price_selector.as_str())
        .iter()
        .next()
    {
        None => {
            println!("Unable to retrieve price element");
            "".to_string()
        }
        Some(price) => price.text().to_string(),

Updated dependencies

The project was using some outdated dependencies, I create a draft pull request (#22) that updates every dependency expect cssparser. There are no breaking changes but the cssparser update is blocked by servo/servo#28368 first,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.