Rosetta Code/Count examples: Difference between revisions

→‎{{header|Go}}: library change
(→‎{{header|Ruby}}: URI.escape has problems (like not escaping '=') and is obsolete with Ruby 1.9.2. Use URI.encode_www_form or CGI.escape.)
(→‎{{header|Go}}: library change)
Line 357:
"os"
"strings"
"url"
"xml"
)
 
func req(urlu string, foundCm func(string)) string {
resp, err := http.Get(urlu)
if err != nil {
fmt.Println(err) // connection or request fail
Line 385 ⟶ 386:
case s.Name.Local == "categorymembers" && len(s.Attr) > 0 &&
s.Attr[0].Name.Local == "cmcontinue":
return httpurl.URLEscapeQueryEscape(s.Attr[0].Value)
}
}
Line 407 ⟶ 408:
func count(cm string) {
taskFmt := "http://rosettacode.org/mw/index.php?title=%s&action=raw"
taskEsc := httpurl.URLEscapeQueryEscape(strings.Replace(cm, " ", "_", -1))
resp, err := http.Get(fmt.Sprintf(taskFmt, taskEsc))
var page []byte
1,707

edits