Webpage.rs
Small library to fetch info about a web page: title, description, language, HTTP info, links, RSS feeds, Opengraph, Schema.org, and more
Usage
use ;
let info = from_url
.expect;
// the HTTP transfer info
let http = info.http;
assert_eq!;
assert!;
assert!;
assert_eq!; // followed redirects (HTTPS)
assert_eq!;
// the parsed HTML info
let html = info.html;
assert_eq!;
assert_eq!;
assert_eq!;
You can also get HTML info about local data:
use HTML;
let html = HTMLfrom_file;
// or let html = HTML::from_string(input, None);
Features
Serialization
If you need to be able to serialize the data provided by the library using
serde, you can include specify the serde feature while
declaring your dependencies in Cargo.toml:
= { = "2.0", = ["serde"] }
No curl dependency
The curl feature is enabled by default but is optional. This is useful if you
do not need a HTTP client but already have the HTML data at hand.
URL schemes and security
HTTP::fetch and Webpage::from_url require an explicit HTTP or HTTPS scheme;
other schemes and scheme-less URLs are rejected. URLs are rejected if any
resolved address is non-public, including private, loopback, and link-local
addresses. Redirects are checked for these constraints too
For trusted URLs that need libcurl's scheme, address, proxy, and redirect
behavior, use HTTP::fetch_unrestricted or Webpage::from_url_unrestricted.
All fields
// Facebook's Opengraph structured data
// Google's schema.org structured data
Options
The following HTTP configurations are available:
// usage
let mut options = default;
options.allow_insecure = true;
let info = from_url.expect;