Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet
Created September 28, 2020 04:49
Show Gist options
  • Save yehgdotnet/afccccdd27da4a874a0fd4ae6bd71530 to your computer and use it in GitHub Desktop.
Save yehgdotnet/afccccdd27da4a874a0fd4ae6bd71530 to your computer and use it in GitHub Desktop.
Go read url from file (change target to your desired domain)
package main
import (
"fmt"
"regexp"
"io/ioutil"
"log"
"os"
)
func main() {
argsWithoutProg := os.Args[1]
content, err := ioutil.ReadFile(argsWithoutProg)
if err != nil {
log.Fatal(err)
}
str1 := string(content)
re := regexp.MustCompile(`(https:\/\/www\.target\/?)([a-zA-Z0-9\-\.]){1,200}`)
//fmt.Printf("Pattern: %v\n", re.String()) // print pattern
//fmt.Println(re.MatchString(str1)) // true
submatchall := re.FindAllString(str1, -1)
for _, element := range submatchall {
fmt.Println(element)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment