craig

package module
v0.0.0-...-aac739e Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: MIT Imports: 14 Imported by: 0

README

craig

GoDoc

Craigslist.org wrapper for Go. This is a fork of https://github.com/sosedoff/go-craigslist which adds some extra features and includes a bit of cleanup.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MultiSearch

func MultiSearch(sites []string, opts SearchOptions) (map[string]*SearchResults, error)

func StartServer

func StartServer(addr string) error

Types

type Image

type Image struct {
	Small  string `json:"small"`
	Medium string `json:"medium"`
	Large  string `json:"large"`
}

type Listing

type Listing struct {
	ID          string            `json:"id"`
	Title       string            `json:"title"`
	Description string            `json:"description,omitempty"`
	URL         string            `json:"url"`
	Price       uint              `json:"price"`
	Images      []Image           `json:"images"`
	Attributes  map[string]string `json:"attributes,omitempty"`
	Location    *Location         `json:"location,omitempty"`
	PostedAt    *time.Time        `json:"posted_at,omitempty"`
	UpdatedAt   *time.Time        `json:"updated_at,omitempty"`
}

func GetListing

func GetListing(url string) (*Listing, error)

func ParseListing

func ParseListing(reader io.Reader) (*Listing, error)

func (*Listing) JSON

func (l *Listing) JSON() (string, error)

type Location

type Location struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

type SearchOptions

type SearchOptions struct {
	Category         string `form:"category"`
	Query            string `form:"query"`
	TitlesOnly       bool   `form:"titles_only"`
	HasImage         bool   `form:"has_image"`
	PostedToday      bool   `form:"posted_today"`
	BundleDuplicates bool   `form:"bundle_duplicates"`
	IncludeNearby    bool   `form:"include_nearby"`
	MinPrice         int    `form:"min_price"`
	MaxPrice         int    `form:"max_price"`
	Skip             int    `form:"skip"`
	Params           map[string]string
}

type SearchResults

type SearchResults struct {
	RangeFrom  int       `json:"range_from"`
	RangeTo    int       `json:"range_to"`
	TotalCount int       `json:"total_count"`
	Listings   []Listing `json:"listings"`
}

func ParseSearchResults

func ParseSearchResults(reader io.Reader) (*SearchResults, error)
func Search(siteId string, opts SearchOptions) (*SearchResults, error)

func SearchByURL

func SearchByURL(searchURL string) (*SearchResults, error)

type Site

type Site struct {
	ID         string
	Name       string
	RegionID   string
	RegionName string
	URL        string
}

func ParseSites

func ParseSites(reader io.Reader) ([]Site, error)

ParseSites extracts all sites from the reader

func Sites

func Sites() ([]Site, error)

Sites returns all US-based sites

Jump to

Keyboard shortcuts

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