{"id":118529,"date":"2024-02-04T10:00:29","date_gmt":"2024-02-04T01:00:29","guid":{"rendered":"https:\/\/softantenna.com\/blog\/?p=118529"},"modified":"2024-02-04T08:36:42","modified_gmt":"2024-02-03T23:36:42","slug":"curlyq","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/curlyq\/","title":{"rendered":"CurlyQ - curl\u3092\u5229\u7528\u3057\u305fWeb\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u30c4\u30fc\u30eb"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2024\/02\/s_20240202_115206.jpg\" alt=\"S 20240202 115206\" title=\"s_20240202_115206.jpg\" border=\"0\" width=\"860\" height=\"560\" \/><\/p>\n<p>curl\u306fHTTP\u3092\u306f\u3058\u3081\u3068\u3057\u305f\u69d8\u3005\u306a\u901a\u4fe1\u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u5bfe\u5fdc\u3057\u305f\u30c7\u30fc\u30bf\u8ee2\u9001\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<p>\u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300c<a href=\"https:\/\/github.com\/ttscoff\/curlyq\">CurlyQ<\/a>\u300d\u306f\u3001\u3053\u306ecurl\u3092\u5185\u90e8\u7684\u306b\u5229\u7528\u3059\u308bRuby\u88fd\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u753b\u50cf\u3084\u30ea\u30f3\u30af\u306e\u62bd\u51fa\u3001\u8981\u7d20\u306e\u691c\u7d22\u3001\u30d8\u30c3\u30c0\u30fc\u60c5\u5831\u306e\u53d6\u5f97\u306a\u3069\u3001\u4fbf\u5229\u306a\u8ffd\u52a0\u6a5f\u80fd\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<p>\u51fa\u529b\u306f\u69cb\u9020\u5316\u30c7\u30fc\u30bf\u300cJSON\u300d\u307e\u305f\u306f\u300cYAML\u300d\u3068\u3057\u3066\u51fa\u529b\u3055\u308c\u3001\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u62bd\u51fa\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u8a08\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u3001\u4f7f\u7528\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<h2>CurlyQ\u306e\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>CurlyQ\u306fRubyGems\u3068\u3057\u3066\u4f5c\u6210\u3055\u308c\u3066\u304a\u308a\u3001gem\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\ngem install curlyq\r\n<\/pre>\n<p>Homebrew\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u5834\u5408\u3001brew-gem\u306b\u3088\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\r\nbrew install brew-gem\r\nbrew gem install curlyq\r\n<\/pre>\n<p>curlyq\u306e\u4f7f\u7528\u65b9\u6cd5\u306f<code>curlyq help<\/code>\u3067\u78ba\u8a8d\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre>\r\nNAME\r\n    curlyq - A scriptable interface to curl\r\n\r\nSYNOPSIS\r\n    curlyq [global options] command [command options] [arguments...]\r\n\r\nVERSION\r\n    0.0.11\r\n\r\nGLOBAL OPTIONS\r\n    --help          - Show this message\r\n    --[no-]pretty   - Output \"pretty\" JSON (default: enabled)\r\n    --version       - Display the program version\r\n    -y, --[no-]yaml - Output YAML instead of json\r\n\r\nCOMMANDS\r\n    extract    - Extract contents between two regular expressions\r\n    headlinks  - Return all <head> links on URL's page\r\n    help       - Shows a list of commands or help for one command\r\n    html, curl - Curl URL and output its elements, multiple URLs allowed\r\n    images     - Extract all images from a URL\r\n    json       - Get a JSON response from a URL, multiple URLs allowed\r\n    links      - Return all links on a URL's page\r\n    scrape     - Scrape a page using a web browser, for dynamic (JS) pages. Be sure to have the selected --browser installed.\r\n    screenshot - Save a screenshot of a URL\r\n    tags       - Extract all instances of a tag\r\n<\/pre>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3001<code>curlyq \u30b3\u30de\u30f3\u30c9 \u30aa\u30d7\u30b7\u30e7\u30f3<\/code>\u3068\u3044\u3046\u5f62\u5f0f\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u304c\u5b58\u5728\u3057\u307e\u3059:<\/p>\n<ul>\n<li><strong>extract<\/strong> - 2\u3064\u306e\u6b63\u898f\u8868\u73fe\u9593\u306e\u5185\u5bb9\u3092\u62bd\u51fa\u3059\u308b<\/li>\n<li><strong>headlinks<\/strong> - URL\u306e\u30da\u30fc\u30b8\u306b\u3042\u308b\u3059\u3079\u3066\u306e<head>\u30ea\u30f3\u30af\u3092\u8fd4\u3059<\/li>\n<li><strong>help<\/strong> - \u30b3\u30de\u30f3\u30c9\u306e\u30ea\u30b9\u30c8\u3001\u307e\u305f\u306f1\u3064\u306e\u30b3\u30de\u30f3\u30c9\u306e\u30d8\u30eb\u30d7\u3092\u8868\u793a\u3059\u308b<\/li>\n<li><strong>html, curl<\/strong> - URL\u3092Curl\u3057\u3001\u305d\u306e\u8981\u7d20\u3092\u51fa\u529b\u3059\u308b\u3002<\/li>\n<li><strong>images<\/strong> - URL\u304b\u3089\u3059\u3079\u3066\u306e\u753b\u50cf\u3092\u62bd\u51fa\u3059\u308b<\/li>\n<li><strong>json<\/strong> - URL\u304b\u3089JSON\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d6\u5f97\u3059\u308b\u3002<\/li>\n<li><strong>links<\/strong> - URL\u306e\u30da\u30fc\u30b8\u306b\u3042\u308b\u3059\u3079\u3066\u306e\u30ea\u30f3\u30af\u3092\u8fd4\u3059<\/li>\n<li><strong>scrape<\/strong> - \u30a6\u30a7\u30d6\u30d6\u30e9\u30a6\u30b6\u3092\u4f7f\u3063\u3066\u30da\u30fc\u30b8\u3092\u30b9\u30af\u30ec\u30a4\u30d7\u3059\u308b\u3002\u5fc5\u305a\u9078\u629e\u3055\u308c\u305f--browser\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li><strong>screenshot<\/strong> - URL\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u3002<\/li>\n<li><strong>tags<\/strong> - \u3042\u308b\u30bf\u30b0\u306e\u3059\u3079\u3066\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u62bd\u51fa\u3059\u308b<\/li>\n<\/ul>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u306f<code>--search(-s)<\/code>\u3068<code>--query(-q)<\/code>\u304c\u91cd\u8981\u3067\u3059\u3002<code>--search<\/code>\u306fCSS\u304bXPath\u69cb\u6587\u306e\u3069\u3061\u3089\u304b\u3092\u4f7f\u3063\u3066\u8981\u7d20\u3092\u63a2\u3059\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002id\u304cmain\u3068\u3044\u3046\u8981\u7d20\u3092\u63a2\u3057\u305f\u3044\u5834\u5408\u3001<code>-s '#main'<\/code>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><code>-q<\/code>\u306f\u51fa\u529b\u3092\u8abf\u6574\u3059\u308b\u305f\u3081\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3059\u3002\u4f8b\u3048\u3070<code>html<\/code>\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u306b\u306f<code>images<\/code>\u3068\u3044\u3046\u30ad\u30fc\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u305f\u3081\u3001<code>-q 'images'<\/code>\u3067\u3001\u753b\u50cf\u306b\u95a2\u3059\u308b\u60c5\u5831\u3060\u3051\u3092\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u8e0f\u307e\u3048\u3001\u4f8b\u3048\u3070<code>curlyq tags --search 'h2'  https:\/\/softantenna.com<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306a\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3001<code>https:\/\/softantenna.com<\/code>\u306b\u542b\u307e\u308c\u308b<code>h2<\/code>\u30bf\u30b0\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<\/p>\n<pre>\r\n\r\n$ curlyq tags --search 'h2'  https:\/\/softantenna.com\r\n[\r\n  {\r\n    \"tag\": \"h2\",\r\n    \"source\": \"&lt;h2 class=\\\"mb-4\\\"&gt;&lt;a href=\\\"\/folders\/all\\\"&gt;\u30bd\u30d5\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea&lt;\/a&gt;&lt;\/h2&gt;\",\r\n    \"attrs\": {\r\n      \"class\": [\r\n        \"mb-4\"\r\n      ]\r\n    },\r\n    \"content\": \"\u30bd\u30d5\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\",\r\n    \"tags\": [\r\n      {\r\n        \"tag\": \"a\",\r\n        \"source\": \"&lt;a href=\\\"\/folders\/all\\\"&gt;\u30bd\u30d5\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea&lt;\/a&gt;\",\r\n        \"attrs\": {\r\n          \"href\": \"\/folders\/all\"\r\n        },\r\n        \"content\": \"\u30bd\u30d5\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea\",\r\n        \"tags\": [\r\n\r\n        ]\r\n      }\r\n    ]\r\n  },\r\n  {\r\n    \"tag\": \"h2\",\r\n    \"source\": \"&lt;h2 class=\\\"mt-4 mb-2\\\"&gt;\u304a\u77e5\u3089\u305b&lt;\/h2&gt;\",\r\n    \"attrs\": {\r\n      \"class\": [\r\n        \"mt-4\",\r\n        \"mb-2\"\r\n      ]\r\n    },\r\n    \"content\": \"\u304a\u77e5\u3089\u305b\",\r\n    \"tags\": [\r\n\r\n    ]\r\n  },\r\n  {\r\n    \"tag\": \"h2\",\r\n    \"source\": \"&lt;h2 class=\\\"mt-5 mb-4\\\"&gt;\u30bd\u30d5\u30c8\u66f4\u65b0\u60c5\u5831 - \u6700\u65b09\u65e5\u5206(1\/3)&lt;\/h2&gt;\",\r\n    \"attrs\": {\r\n      \"class\": [\r\n        \"mt-5\",\r\n        \"mb-4\"\r\n      ]\r\n    },\r\n    \"content\": \"\u30bd\u30d5\u30c8\u66f4\u65b0\u60c5\u5831 - \u6700\u65b09\u65e5\u5206(1\/3)\",\r\n    \"tags\": [\r\n\r\n    ]\r\n  }\r\n]\r\n<\/pre>\n<p>\u3053\u306e\u4e2d\u304b\u3089<code>source<\/code>\u306e\u60c5\u5831\u304c\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3001<code>--query 'source'<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n$ curlyq tags --search 'h2' --query 'source' https:\/\/softantenna.com\r\n[\r\n  \"&lt;h2 class=\\\"mb-4\\\"&gt;&lt;a href=\\\"\/folders\/all\\\"&gt;\u30bd\u30d5\u30c8\u30e9\u30a4\u30d6\u30e9\u30ea&lt;\/a&gt;&lt;\/h2&gt;\",\r\n  \"&lt;h2 class=\\\"mt-4 mb-2\\\"&gt;\u304a\u77e5\u3089\u305b&lt;\/h2&gt;\",\r\n  \"&lt;h2 class=\\\"mt-5 mb-4\\\"&gt;\u30bd\u30d5\u30c8\u66f4\u65b0\u60c5\u5831 - \u6700\u65b09\u65e5\u5206(1\/3)&lt;\/h2&gt;\"\r\n]%<\/pre>\n<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2024\/02\/s_20240202_133442.jpg\" alt=\"S 20240202 133442\" title=\"s_20240202_133442.jpg\" border=\"0\" width=\"860\" height=\"560\" \/><\/p>\n<p>\u305d\u306e\u4ed6\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f8b\u304c\u63b2\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>headlinks\u306e\u4f8b<\/strong>:<\/p>\n<pre>\r\ncurlyq headlinks -q '[rel=stylesheet]' https:\/\/brettterpstra.com\r\n<\/pre>\n<p><code>&lt;head&gt;<\/code>\u304b\u3089\u3059\u3079\u3066\u306e<code>&lt;link&gt;<\/code>\u3092\u53d6\u308a\u51fa\u3057\u3001<code>-q<\/code>\u3092\u4f7f\u3063\u3066<code>rel=\"stylesheet\"<\/code>\u3092\u6301\u3064\u30ea\u30f3\u30af\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3002<\/p>\n<p><strong>html\u306e\u4f8b<\/strong>:<\/p>\n<pre>\r\ncurlyq html -s '#main article .aligncenter' -q 'images[1]' 'https:\/\/brettterpstra.com'\r\n<\/pre>\n<p>\u30da\u30fc\u30b8\u306e\u5168html\u3092\u7167\u4f1a\u3057\u3001<code>--search<\/code>\u3092\u4f7f\u3063\u3066\u8981\u7d20\u3092\u7d5e\u308a\u8fbc\u307f\u3001\u305d\u306e\u7d50\u679c\u304b\u30892\u756a\u76ee\u306e\u753b\u50cf\u3092\u53d6\u308a\u51fa\u3059\u3002<\/p>\n<p><strong>images\u306e\u4f8b<\/strong>: <\/p>\n<pre>\r\ncurlyq images -t img -q '[alt$=screenshot]' https:\/\/brettterpstra.com\r\n<\/pre>\n<p><code>&lt;img&gt;<\/code>\u30bf\u30b0\u306e\u753b\u50cf\u306e\u914d\u5217\u3092\u53d6\u5f97\u3057\u3001alt\u5c5e\u6027\u304cscreenshot\u3067\u7d42\u308f\u308b\u3082\u306e\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u3002<\/p>\n<p>CurlyQ\u306b\u306f\u591a\u6570\u306e\u30b3\u30de\u30f3\u30c9\u3084\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u8a73\u7d30\u306f<a href=\"https:\/\/github.com\/ttscoff\/curlyq\">GitHub<\/a>\u306b\u3066\u78ba\u8a8d\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>CurlyQ\u306fcurl\u3092\u3055\u3089\u306b\u4fbf\u5229\u5316\u3059\u308b\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4e00\u5ea6\u306b\u3059\u3079\u3066\u306e\u6a5f\u80fd\u3092\u4f7f\u3044\u3053\u306a\u3059\u306e\u306f\u5927\u5909\u3067\u3059\u304c\u3001\u7c21\u5358\u306a\u4f8b\u304b\u3089\u5c11\u3057\u305a\u3064\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304f\u3053\u3068\u3067\u6163\u308c\u3066\u3044\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>curl\u306fHTTP\u3092\u306f\u3058\u3081\u3068\u3057\u305f\u69d8\u3005\u306a\u901a\u4fe1\u30d7\u30ed\u30c8\u30b3\u30eb\u306b\u5bfe\u5fdc\u3057\u305f\u30c7\u30fc\u30bf\u8ee2\u9001\u30c4\u30fc\u30eb\u3067\u3059\u3002 \u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300cCurlyQ\u300d\u306f\u3001\u3053\u306ecurl\u3092\u5185\u90e8\u7684\u306b\u5229\u7528\u3059\u308bRuby\u88fd\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u753b\u50cf\u3084\u30ea\u30f3\u30af\u306e\u62bd\u51fa\u3001\u8981\u7d20\u306e\u691c\u7d22\u3001\u30d8\u30c3\u30c0\u30fc\u60c5\u5831\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":118573,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3459],"tags":[3071],"class_list":["post-118529","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","tag-curl"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/118529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=118529"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/118529\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/118573"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=118529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=118529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=118529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}