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