scraper-rest

command module
v0.0.0-...-4081b50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2021 License: MIT Imports: 9 Imported by: 0

README

scraper-rest

scraper-rest

scraper-rest serves simple image scrapper as REST API.

Installation

Clone this repository to your local environment. Then, start the server.

$ git clone https://github.com/buraksekili/scraper-rest.git
$ cd scraper-rest
$ go run main.go

Usage

The server accepts POST requests from port :5000

$ curl localhost:5000/images -d '{"url":"https://golang.org/pkg/net/http/"}'

It returns JSON response as follows;

[{"image":"https://golang.org/lib/godoc/images/go-logo-blue.svg","image_name":"/lib/godoc/images/go-logo-blue.svg"},{"image":"https://golang.org/lib/godoc/images/footer-gopher.jpg","image_name":"/lib/godoc/images/footer-gopher.jpg"}]

If jq is installed, you can pipe the JSON result to get better view.

$ curl localhost:5000/images -d '{"url":"https://golang.org/pkg/net/http/"}' | jq

[
  {
    "image": "https://golang.org/lib/godoc/images/go-logo-blue.svg",
    "image_name": "/lib/godoc/images/go-logo-blue.svg"
  },
  {
    "image": "https://golang.org/lib/godoc/images/footer-gopher.jpg",
    "image_name": "/lib/godoc/images/footer-gopher.jpg"
  }
]

Acknowledgments

Image scraper is based on Chapter 5 of the The Go Programming Language

Highly inspired by this repo.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL