Skip to content

Commit

Permalink
HTTP request to Billboard now works
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-pierce committed Sep 6, 2021
1 parent e13d9ad commit b28ad18
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module billboard-scraper

go 1.16
5 changes: 4 additions & 1 deletion main/main.go → main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package main

import (
"billboard-scraper/scraper"
"fmt"
"os"
)

func main() {
fmt.Printf("%d", len(os.Args))
fmt.Println("%d", len(os.Args))
fmt.Println("What artist would you like to search?")

scraper.GetHTML()
}
Binary file added main/.DS_Store
Binary file not shown.
38 changes: 37 additions & 1 deletion scraper/scraper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
package scraper

import (
"fmt"
"io"
"strings"
"log"
"net/http"
)

type LinkTag struct {
linkRef string
linkText string
}

func GetHTML() (bool, error) {
resp, err := http.Get("https://www.billboard.com/charts/hot-100")

if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)

if err != nil {
log.Fatalln(err)
}

fmt.Print(string(body))
return true, nil

}

// func ParseHTML(r io.Reader) ([]LinkTag, error) {
// doc, err := html.Parse(r)

// if err != nil {
// return nil, err
// }
// return nil, nil

// return doc
// }

0 comments on commit b28ad18

Please sign in to comment.