Skip to content

Instantly share code, notes, and snippets.

@henteko
Created August 20, 2014 16:28
Show Gist options
  • Save henteko/f65ab90f6320847286c6 to your computer and use it in GitHub Desktop.
Save henteko/f65ab90f6320847286c6 to your computer and use it in GitHub Desktop.
zoiをコピーするやつ
package main
import (
"fmt"
"github.com/atotto/clipboard"
"io/ioutil"
"math/rand"
"net/http"
"regexp"
"time"
)
func main() {
rand.Seed(time.Now().UTC().UnixNano())
resp, err := http.Get("https://raw.githubusercontent.com/eiurur/zoi/master/public/js/services.js")
if err != nil {
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
js := string(body)
r, _ := regexp.Compile("(https://.+):large")
allString := r.FindAllString(string(js), -1)
urls := make([]string, len(allString))
for index, element := range allString {
url := r.FindStringSubmatch(element)[1]
urls[index] = url
}
zoiUrl := urls[rand.Intn(len(urls))]
err = clipboard.WriteAll(zoiUrl)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Copy Success", zoiUrl)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment