File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ package main
22
33import (
44 "fmt"
5+
56 "github.com/anaskhan96/soup"
67)
78
89func main () {
9- fmt .Println ("Enter the url of the xkcd comic :" )
10- var url string
11- fmt .Scanf ("%s" , & url )
10+ fmt .Println ("Enter the xkcd comic number :" )
11+ var num int
12+ fmt .Scanf ("%d" , & num )
13+ url := fmt .Sprintf ("https://xkcd.com/%d" , num )
1214 resp , _ := soup .Get (url )
1315 doc := soup .HTMLParse (resp )
1416 title := doc .Find ("div" , "id" , "ctitle" ).Text ()
@@ -19,8 +21,8 @@ func main() {
1921}
2022
2123/* --- Console I/O ---
22- Enter the url of the xkcd comic :
23- https://xkcd.com/ 353
24+ Enter the xkcd comic number :
25+ 353
2426Title of the comic : Python
2527Source of the image : //imgs.xkcd.com/comics/python.png
2628Underlying text of the image : I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you.
You can’t perform that action at this time.
0 commit comments