#curl #string #command #developer #browser #copied #pattern

parser4curls

从浏览器开发者工具中复制的cURL命令字符串的解析器,或与模式兼容的字符串 curl <url> [options...]

2个版本

0.1.1 2021年7月25日
0.1.0 2021年7月25日

#5 in #copied

MIT许可证

370KB
294 代码行

parser4curls

从浏览器开发者工具中复制的cURL命令字符串的解析器,或与模式兼容的字符串 curl <url> [options...]

unittest

Copy as cURL from developer tools in chrome

兼容性

curl <url> [options...]

从Chrome/Edge、Safari、Firefox等类似浏览器中复制。

示例

use parser4curls::parse;

fn main() {
    let input = r#"curl 'https://www.google.com/search?q=Tokyo&rlz=1C5CHFA_enJP651JP651&oq=Tokyo&aqs=chrome..69i57j69i65.262j0j1&sourceid=chrome&ie=UTF-8' \
  -H 'authority: www.google.com' \
  -H 'cache-control: max-age=0' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'upgrade-insecure-requests: 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36' \
  -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
  -H 'sec-fetch-site: same-origin' \
  -H 'sec-fetch-mode: navigate' \
  -H 'sec-fetch-user: ?1' \
  -H 'sec-fetch-dest: document' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cookie: CGIC=d2VicCxpbWFnZS9hc; NID=219=3XwFj5FYc2Jtkwl5K-QM2cWdxv8Am9t14-zH1QzxtHWEUT3BMg; DV=kyQKkk0J-HU_sc0eciTCQs_p7gJQEAAAA' \
  --compressed"#;

    if let Ok(r) = parse(input) {
        println!("{:#?}", r.1);
    }
}

依赖项

~2.5MB
~59K SLoC