15 releases

0.3.0 Jan 8, 2024
0.2.9 Jan 6, 2024
0.2.7 Sep 21, 2023
0.1.4 Sep 12, 2023

#2843 in Parser implementations


Used in graburl

MIT license

7KB
58 lines

Ahref

Extract "a" tags from html page

Installation

You can install Ahref using cargo:

cargo add ahref

Usage

Here's an example of how to use Ahref lib:

use ahref::Parser;

fn main() {
    let html = "<a href='https://github.com/tenqz'>Test link</a>".to_string();
    let mut parser = Parser::new(html);
    println!("{:?}", parser.parse_tags());
}

As a result, all "a" tags will be displayed.

["<a href='https://github.com/tenqz'>Test link</a>"]
use ahref::Parser;

fn main() {
    let html = "<a href='https://github.com/tenqz'>Test link</a>".to_string();
    let mut parser = Parser::new(html);
    println!("{:?}", parser.parse_links());
}

As a result, all urls will be displayed.

["https://github.com/tenqz"]

Dependencies

~2.2–3MB
~53K SLoC