-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.go
42 lines (34 loc) · 996 Bytes
/
2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
)
// re
// Compile(expr string)
// MustCompile(expr string) - like Compile but panic if expr cannot be parsed
func main(){
URL := "http://www.pythonchallenge.com/pc/def/ocr.html"
response, _ := http.Get( URL )
defer response.Body.Close()
body, _ := ioutil.ReadAll( response.Body )
re := regexp.MustCompile(`(?s)<!--(.*?)-->`)
matches := re.FindAllStringSubmatch(string(body), -1)
fmt.Println("len/", len(matches))
instr, cipher := matches[0][1], matches[1][1]
fmt.Println("\ncipher/", cipher[:42 * 10])
fmt.Println("\nmanual/", instr)
dict := make(map[rune]int)
res := []rune{}
for _, c := range (cipher) {
if ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') {
res = append(res, c)
dict[c]++
}
}
for k, v := range dict {
fmt.Printf("%c/ %d \n", rune(k), v)
}
fmt.Println("res/", string(res))
}