zlistutil

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

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

Go to latest
Published: Aug 1, 2015 License: MIT Imports: 8 Imported by: 1

README

zlistutil

简介

一个工具库,提供了获取 V2EX、知乎日报、HackerNews、简书、ProductHunt 等站点最热信息的方法。

使用方法

package main

import (
	"encoding/json"
	"fmt"
	"github.com/zlisthq/zlistutil"
	"log"
)

func main() {
	items := zlistutil.GetItem(zlistutil.SITE_V2EX, zlistutil.V2EX_HOT, 10)
	json_items, err := json.Marshal(&items)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(json_items))
}

使用该工具的站点

添加站点

请提交待添加的网址到 Issues

待添加站点

Documentation

Index

Constants

View Source
const (
	//SITE NAME
	SITE_V2EX         = "v2ex"
	SITE_ZHIHUDAILY   = "zhihu_daily"
	SITE_HACKERNEWS   = "hackernews"
	SITE_JIANSHU      = "jianshu"
	SITE_PRODUCTHUNT  = "producthunt"
	SITE_NEXT         = "next"
	SITE_WANQU        = "wanqu"
	SITE_PINGWEST     = "pingwest"
	SITE_SOLIDOT      = "solidot"
	SITE_GITHUB       = "github"
	SITE_DOUBANMOMENT = "douban_moment"
	SITE_IFANR        = "ifanr"
	SITE_MINDSTORE    = "mindstore"
	SITE_KICKSTARTER  = "kickstarter"
	SITE_GADGETHUNT   = "gadgethunt"
	SITE_TOUTIAO      = "toutiao"
	SITE_SEGMENTFAULT = "segmentfault"
	SITE_THEPAPER     = "thepaper"
	SITE_GUOKR        = "guokr"

	/* URL */
	// V2ex
	V2EX_BASE_URL = "https://www.v2ex.com/api/topics/"
	V2EX_HOT      = "https://www.v2ex.com/api/topics/hot.json"
	V2EX_LATEST   = "https://www.v2ex.com/api/topics/latest.json"
	// Zhihu Daily
	DAILY_FETCH_NOW    = "http://news.at.zhihu.com/api/1.2/news/latest"
	DAILY_FETCH_BEFORE = "http://news.at.zhihu.com/api/1.2/news/before/"
	//Hacker News
	HACKER_NEWS_BASE_URL     = "https://news.ycombinator.com"
	HACKER_NEWS_BASE_API_URL = "https://hacker-news.firebaseio.com"
	HACKER_NEWS_TOP          = "https://hacker-news.firebaseio.com/v0/topstories.json"
	HACKER_NEWS_ITEM         = "https://hacker-news.firebaseio.com/v0/item/"
	// Jianshu
	JIANSHU_BASE_URL = "http://www.jianshu.com"
	JIANSHU_TOP_DAY  = "http://www.jianshu.com/trending/now"
	// Product Hunt
	PRODUCTHUNT_TODAY     = "https://api.producthunt.com/v1/posts"
	PRODUCTHUNT_YESTERDAY = "https://api.producthunt.com/v1/posts?days_ago=1"
	//36kr NEXT
	NEXT_BASE_URL = "http://next.36kr.com"
	NEXT          = "http://next.36kr.com/posts"
	//湾区日报
	WANQU = "http://wanqu.co"
	//PingWest快讯
	PINGWEST_NEWS = "http://news.pingwest.com/"
	//Solidot
	SOLIDOT = "http://www.solidot.org"
	//GitHub
	GITHUB_BASE_URL = "https://github.com"
	GITHUB          = "https://github.com/trending"
	//豆瓣 一刻
	DOUBAN_MOMENT = "http://moment.douban.com/api/stream/date/"
	//ifanr 观察
	IFANR = "http://www.ifanr.com"
	//mindstore
	MINDSTORE = "http://mindstore.io"
	//Kickstarter technology newest
	KICKSTARTER_BASE_URL = "https://www.kickstarter.com"
	KICKSTARTER          = "https://www.kickstarter.com/discover/categories/technology?sort=newest"
	//gadgethunt daily
	GADGETHUNT = "http://www.gadgethunt.club/daily"
	//toutiao.io
	TOUTIAO = "http://toutiao.io"
	//segmentfault
	SEGMENTFAULT_BASE_URL = "http://segmentfault.com"
	SEGMENTFAULT_BLOG     = "http://segmentfault.com/blogs"
	//thepaper
	THEPAPER = "http://www.thepaper.cn/"
	//果壳精选
	GUOKR_HANDPICK = "http://apis.guokr.com/handpick/article.json?ad=1&category=all&retrieve_type=by_since"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyItems

type DailyItems struct {
	News []struct {
		Title string `json:"title"`
		Url   string `json:"share_url"`
	}
}

type GuokrItems

type GuokrItems struct {
	Result []struct {
		Title string `json:"title"`
		Url   string `json:"page_source"`
	}
}

type Item

type Item struct {
	Title string `json:"title"`
	Url   string `json:"url"`
}

func GetItem

func GetItem(site string, url string, num int) []Item

type MomentItems

type MomentItems struct {
	Posts []struct {
		Title string `json:"title"`
		Url   string `json:"url"`
	}
}

type ProductHuntsItems

type ProductHuntsItems struct {
	Posts []struct {
		Name    string `json:"name"`
		Tagline string `json:"tagline"`
		Url     string `json:"redirect_url"`
	}
}

Jump to

Keyboard shortcuts

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