serps/cli

终端爬虫命令行工具

安装: 631

依赖: 3

建议者: 0

安全性: 0

星标: 14

关注者: 5

分支: 7

开放问题: 2

类型:项目

v1.2.0 2018-09-07 08:30 UTC

This package is auto-updated.

Last update: 2024-09-06 19:05:26 UTC


README

终端爬虫命令行工具

安装

您可以使用 composer 全局安装它

composer global require serps/cli

通过调用帮助信息测试安装

serps help

Google

搜索

搜索命令允许从命令行触发 Google 搜索

serps google:search "keyword"

示例

    $ serps google:search "github"
    {
      "natural-results": [
        {
          "url": "https://github.com/",
          "title": "How people build software · GitHub",
          "types": [
            "classical",
            "classical_large"
          ]
        },
        {
          "url": "https://fr.wikipedia.org/wiki/GitHub",
          "title": "GitHubWikipédia",
          "types": [
            "classical"
          ]
        },
        {
          "url": "https://en.wikipedia.org/wiki/GitHub",
          "title": "GitHub - Wikipedia, the free encyclopedia",
          "types": [
            "classical"
          ]
        },
        {
          "url": "http://rue89.nouvelobs.com/2015/03/31/quest-tous-les-techos-monde-font-github-258439",
          "title": "Qu'est-ce que tous les techos du monde font sur GitHub ? - Rue89 - L ...",
          "types": [
            "classical"
          ]
        },
        {
          "url": "https://twitter.com/github?lang=fr",
          "title": "GitHub (@github) | Twitter",
          "types": [
            "classical"
          ]
        },
        {
          "url": "https://www.githubarchive.org/",
          "title": "GitHub Archive",
          "types": [
            "classical"
          ]
        },
        {
          "url": "https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin",
          "title": "GitHub Plugin - Jenkins - Jenkins Wiki",
          "types": [
            "classical"
          ]
        }
      ],
      "total-count": 1.31e+08,
      "natural-results-count": 7,
      "evaluated": true,
      "http-client": "curl",
      "url": "https://www.google.fr/search?q=github&gws_rd=cr&ei=kH7OV7LaForeU_yGhtgC",
      "initial-url": "https://google.com/search?q=github"
    }

提示:在示例中,jq 有助于美化输出的 json 格式:$ serps google:search "github" | jq '.'

高级使用

    $ serps google:search --tld="co.uk" --lr="lang_es" "some keywords" phantomjs

使用代理:

    $ serps google:search --proxy="http://proxy:8080" "some keywords"

页面和每页结果:

    $ serps google:search --page=2 --res-per-page=20 "some keywords"

用户代理:

    $ serps google:search --user-agent="..." "some keywords"

移动搜索

这是用户代理选项的替代方案,用于使用硬编码的移动用户代理

    $ serps google:search --mobile "some keywords"

将页面存入文件:

除了打印结果,您还可以将 DOM 保存到文件

    $ serps google:search --dump="/path/to/file.html" "some keywords"

默认情况下,如果指定的文件已存在,则不会处理存档选项。强制-dump 选项使其能够覆盖现有文件

    $ serps google:search --dump="/path/to/file.html" --force-dump=true "some keywords"

读取并解析本地保存的 html google 文件 而不是进行 http 查询

    $ serps google:search --file=./google--search-file.html "some keywords"