Created
August 20, 2014 16:28
-
-
Save henteko/f65ab90f6320847286c6 to your computer and use it in GitHub Desktop.
zoiをコピーするやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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