henrywoody / go-craigslist

Craigslist.org wrapper for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-craigslist

Build Status GoDoc

Craigslist.org wrapper for Go

Install

go get -u github.com/sosedoff/go-craigslist

Usage

package main

import (
  "log"

  "github.com/sosedoff/go-craigslist"
)

func main() {
  opts := craigslist.SearchOptions{
    Category: "cto", // cars+trucks
    Query:    "honda",
    HasImage: true,
    MinPrice: 10000,
    MaxPrice: 20000,
  }

  // Perform a search
  result, err := craigslist.Search("chicago", opts)
  if err != nil {
    log.Fatal(err)
  }

  for _, listing := range result.Listings {
    log.Println(listing.JSON())
  }

  // Fetch listing details
  listing, err := craigslist.GetListing(result.Listings[0].URL)
  if err != nil {
    log.Fatal(err)
  }

  log.Println(listing)
}

Test

make test

License

MIT

About

Craigslist.org wrapper for Go

License:MIT License


Languages

Language:HTML 96.4%Language:Go 3.6%Language:Makefile 0.0%