Created
June 7, 2016 22:09
-
-
Save bmitch/98b6b64152e0d13d1af154ddd85fd959 to your computer and use it in GitHub Desktop.
weather scraper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/PuerkitoBio/goquery" | |
"log" | |
"strings" | |
) | |
func main() { | |
url := "http://www.victoriaweather.ca/station.php?id=93" | |
doc, err := goquery.NewDocument(url) | |
if err != nil { | |
log.Fatal(err) | |
} | |
doc.Find(".current_obs tr").Each(func(i int, s *goquery.Selection) { | |
title := s.Find("td").Eq(0).Text() | |
title = strings.Trim(title, " ") | |
value := s.Find("td").Eq(1).Text() | |
fmt.Printf("%15s %-40s\n", title, value) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment