VictorLeP / tranco-go-package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoLang bindings for Tranco List

This is a GoLang bindings for Tranco List. It can be used as a cli tool or a GoLang module.

Cli Installation

go install github.com/WangYihang/tranco/cmd/tranco@latest

Cli Usage

Usage:
  tranco [OPTIONS]

Application Options:
  -i, --input-filepath=           input filepath that contains the domains to be queried (default: -)
  -t, --date=                     date of the list (eg: 2023-01-01) (default: 2020-01-01)
  -s, --second-level-domain-only  whether to use the list of second-level domains (default: false)

Help Options:
  -h, --help                      Show this help message
$ cat input.txt                                                    
google.com
baidu.com
tsinghua.edu.cn
pku.edu.cn

$ cat input.txt | tranco -t 2023-10-10
{"domain":"google.com","rank":1,"date":"2023-10-10"}
{"domain":"baidu.com","rank":138,"date":"2023-10-10"}
{"domain":"tsinghua.edu.cn","rank":5302,"date":"2023-10-10"}
{"domain":"pku.edu.cn","rank":4338,"date":"2023-10-10"}

Module Installation

go get github.com/WangYihang/tranco

Module Usage

package main

import (
	"fmt"
	"github.com/WangYihang/tranco"
)

func main() {
	list, err := tranco.NewTrancoList("2019-04-30", false, "1000")
	if err != nil {
		panic(err)
	}
	rank, err := list.Rank("google.com")
	if err != nil {
		panic(err)
	}
	fmt.Println(rank)
}

Acknowledgement

Special thanks to the authors of the Tranco List and the tranco-python-package for their work, which inspired the creation of this GoLang project.

About

License:MIT License


Languages

Language:Go 100.0%