Module fetch

Module fetch 

Source
Available on crate feature scraper only.
Expand description

数据获取与 HTML 解析辅助模块

在启用 scraper 特性时提供 HTML 解析能力,用于从页面的 <meta name="bmstable" content="..."> 中提取头部 JSON 的地址。 同时提供一个统一的入口将响应字符串解析为头部 JSON 或其 URL。

§示例

let html = r#"
<!DOCTYPE html>
<html>
  <head>
    <meta name="bmstable" content="header.json">
  </head>
  <body></body>
</html>
"#;
match get_web_header_json_value(html).unwrap() {
    HeaderQueryContent::Url(u) => assert_eq!(u, "header.json"),
    _ => unreachable!(),
}

Modules§

reqwestreqwest
基于 reqwest 的网络获取模块

Enums§

HeaderQueryContent
get_web_header_json_value 的返回类型。

Functions§

extract_bmstable_url
从 HTML 页面内容中提取 bmstable 字段指向的 JSON 文件 URL。
get_web_header_json_value
将响应字符串解析为头部 JSON 或其 URL。