qurl

package module
v0.0.0-...-1cac32a Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 5 Imported by: 0

README

qurl

License ReportCard GoDoc

Table of contents

Introduction

Qurl is a drop-in and easy to deploy microservice who exposes an HTTP API you can use to extract content from any web page as JSON. Any information available at a given public URL can be extracted using selector queries (check examples below).

Example:

$ curl -s 'http://localhost:8080/q?url=https://example.com&header=Content-Type&selector=meta' | json_pp
{
   "url" : "https://example.com",
   "status" : 200,
   "selectors" : {
      "meta" : [
         {
            "text" : "",
            "attributes" : [
               {
                 "key" : "charset",
                  "value" : "utf-8"
               }
            ]
         },
         {
           "text" : "",
            "attributes" : [
               {
                  "key" : "name",
                  "value" : "viewport"
               },
               {
                 "key" : "content",
                  "value" : "width=device-width, initial-scale=1"
               }
            ]
         }
      ]
   },
   "headers" : {
      "Content-Type" : [
         "text/html; charset=utf-8"
      ]
   }
}

Installation

To install Qurl:

go get -u github.com/repejota/qurl

And execute the server:

$ qurl --help
Usage of qurl:
  -address string
        Server address
  -port string
        Server port (default "8080")
  -version
        Show version information
Deployment

You can also deploy Qurl on Heroku with this one click button:

Deploy

Documentation

Qurl is really powerful and full of posibilities, that's why we have been creating an entire site that documents all the features you can use.

Plesae refer to the documentation website where you'll gonna find accurated information aboug how to use the API that provides Qurl but also how to download, build and launch your own insgtance of the service.

Visit the documentation

Continuous integration

Tests
  • Develop: CircleCI
  • Master: CircleCI
Coverage
  • Develop: Coverage Status
  • Master: Coverage Status

License

(The MIT License)

Copyright (c) 2017 qurl Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package qurl implements a service to extract the contents of any web page returning the results as a JSON data structure.

This service exports all its functionality through an HTTP REST API and has been designed following the principles on microservices so it can be easily integrated in any existing infrastructure or platform.

In adition of this API reference, there is available also an accurated documentation for end users and developers in the following URL:

https://repejota.github.com/qurl/

Index

Constants

View Source
const (
	// DefaultServerAddress is the default hostname where the server is going to
	// be started and listening.
	DefaultServerAddress = ""

	// DefaultServerPort is the default port number where the server is going to
	// be started and listening.
	DefaultServerPort = "8080"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeRequest

type FakeRequest struct {
	ExpectedStatusCode      int
	ExpectedBody            string
	ExpectedResponseHeaders http.Header
}

FakeRequest ...

func (*FakeRequest) Fetch

func (r *FakeRequest) Fetch(url string) (*http.Response, error)

Fetch performs an HTTP GET call to anURL and fetch the contents.

type IRequest

type IRequest interface {
	Fetch(url string) (*http.Response, error)
}

IRequest ...

type QURL

type QURL struct {
}

QURL is the main interface for the microservice.

func (*QURL) Query

func (q *QURL) Query(ir IRequest, params url.Values) (*Response, error)

Query queries the URL and process all the data we want to fetch.

type Request

type Request struct {
}

Request represents the call being made to retrieve the contents of an URL.

func (*Request) Fetch

func (r *Request) Fetch(url string) (*http.Response, error)

Fetch performs an HTTP GET call to anURL and fetch the contents.

type Response

type Response struct {
	URL       string                `json:"url"`
	Status    int                   `json:"status"`
	Headers   map[string][]string   `json:"headers,omitempty"`
	Selectors map[string][]*element `json:"selectors,omitempty"`
}

Response represents the result struct received after querying an URL. Contains information about the URL and the data retrieved after proessing the content.

func NewResponse

func NewResponse() *Response

NewResponse returns a new response instance.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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