diff --git a/examples/xkcdextract/xkcdextract.go b/examples/xkcdextract/xkcdextract.go index 3340b81..a81ff93 100644 --- a/examples/xkcdextract/xkcdextract.go +++ b/examples/xkcdextract/xkcdextract.go @@ -2,13 +2,15 @@ package main import ( "fmt" + "github.com/anaskhan96/soup" ) func main() { - fmt.Println("Enter the url of the xkcd comic :") - var url string - fmt.Scanf("%s", &url) + fmt.Println("Enter the xkcd comic number :") + var num int + fmt.Scanf("%d", &num) + url := fmt.Sprintf("https://xkcd.com/%d", num) resp, _ := soup.Get(url) doc := soup.HTMLParse(resp) title := doc.Find("div", "id", "ctitle").Text() @@ -19,8 +21,8 @@ func main() { } /* --- Console I/O --- -Enter the url of the xkcd comic : -https://xkcd.com/353 +Enter the xkcd comic number : +353 Title of the comic : Python Source of the image : //imgs.xkcd.com/comics/python.png Underlying text of the image : I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you.