scrapejestad

package module
v0.0.0-...-8dbc89f Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 10 Imported by: 1

README

Scrape je stad

A Go library for scraping data from the Meet je stad project.

This is not affiliated with Meet je stad in any way

Usage

Example program:

package main

import (
    "github.com/fiskeben/scrapejestad"
    "net/url"
)

func main() {
    u, err := url.Parse("https://meetjestad.net/data/sensors_recent.php?sensor=242&limit=10")
    if err != nil {
        panic(err)
    }

    data, err := scrapejestad.Read(u)
    if err != nil {
        panic(err)
    }

    // do stuff to data
    fmt.Printf("first entry: %v\n", data[0])
}

See also

See the meetjescraper HTTP proxy to get a JSON based HTTP API in front of Meet je stad.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gateway

type Gateway struct {
	Name          string        `json:"name"`
	Position      Position      `json:"coordinates"`
	Distance      float32       `json:"distance"`
	RSSI          float32       `json:"rssi"`
	LSNR          float32       `json:"lsnr"`
	RadioSettings RadioSettings `json:"radio_settings"`
}

Gateway holds data about a LoRa:wan gateway a Reading has been sent to.

func (Gateway) String

func (g Gateway) String() string

String returns a string representation of a Gateway.

type JsonReading

type JsonReading struct {
	Row             int     `json:"row"`
	Id              int     `json:"id"`
	Timestamp       string  `json:"timestamp"`
	FirmwareVersion int     `json:"firmware_version"`
	Longitude       float32 `json:"longitude"`
	Latitude        float32 `json:"latitude"`
	Temperature     float32 `json:"temperature"`
	Humidity        float32 `json:"humidity"`
	Supply          float32 `json:"supply"`
}

type Position

type Position struct {
	Lat float32 `json:"lat"`
	Lng float32 `json:"lng"`
}

Position is a coordinate with latitude and longitude.

func (Position) String

func (p Position) String() string

String returns a position as lat:lng.

type RadioSettings

type RadioSettings struct {
	Frequency float32 `json:"frequency"`
	Sf        string  `json:"sf"`
	Cr        string  `json:"cr"`
}

RadioSettings holds data about the radio settings used to transmit a Reading.

func (RadioSettings) String

func (r RadioSettings) String() string

String returns a string representation of RadioSettings.

type Reading

type Reading struct {
	SensorID string    `json:"sensor_id"`
	Time     int64     `json:"timestamp"`
	Date     time.Time `json:"date"`
	Temp     float32   `json:"temperature"`
	Humidity float32   `json:"humidity"`
	Light    float32   `json:"light"`
	PM25     float32   `json:"pm25"`
	PM10     float32   `json:"pm10"`
	Voltage  float32   `json:"voltage"`
	Firmware string    `json:"firmware_version"`
	Position Position  `json:"coordinates"`
	Fcnt     int       `json:"fcnt"`
	Gateways []Gateway `json:"gateways"`
}

Reading represents one unique data point.

func Read

func Read(u *url.URL) ([]Reading, error)

Read downloads a document and parses it.

func ReadWithContext

func ReadWithContext(ctx context.Context, u *url.URL) ([]Reading, error)

ReadWithContext downloads a document and parses it.

func (Reading) String

func (r Reading) String() string

String returns a string representation of a Reading.

Jump to

Keyboard shortcuts

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