2017 © Pedro PelĂĄez
 

project cli

Command line utility to scrape from the terminal

image

serps/cli

Command line utility to scrape from the terminal

  • Tuesday, May 29, 2018
  • by sneakyBobito
  • Repository
  • 4 Watchers
  • 8 Stars
  • 151 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 9 Versions
  • 29 % Grown

The README.md

SERPS cli

Command line utility to scrape from the terminal, (*1)

Install

You can install it globally with composer:, (*2)

composer global require serps/cli

Test installation by invoking the help message, (*3)

serps help

Google

Search command allows to trigger a google search from the command line, (*4)

serps google:search "keyword", (*5)

example

    $ 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": "GitHub — WikipĂ©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"
    }

Tip: In the example jq helped to pretty format the outputted json: $ serps google:search "github" | jq '.', (*6)

Advanced usage

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

With proxy:, (*7)

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

Page and result per page:, (*8)

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

User Ageng:, (*9)

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

Mobile search, (*10)

This is an alertnative to the user agent option to use an hard coded mobile user agent, (*11)

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

Dump page in a file:, (*12)

In a addition of printing the results you can save the dom in a file, (*13)

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

By default the dump option wont be able to process if the file you specify already exists. The option force-dump makes it able to override an existing file:, (*14)

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

Read and parse a html google file saved locally instead of doing http query, (*15)

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

The Versions