Skip to content

Instantly share code, notes, and snippets.

@rohanbk
Last active October 2, 2019 21:23
Show Gist options
  • Save rohanbk/3c65b3de0bbc41671cc0c8893193ff2b to your computer and use it in GitHub Desktop.
Save rohanbk/3c65b3de0bbc41671cc0c8893193ff2b to your computer and use it in GitHub Desktop.
Find list of available burn wards while also memeing when your friends or coworkers get dissed
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/PuerkitoBio/goquery"
)
func main() {
response, err := http.Get("https://en.wikipedia.org/wiki/List_of_burn_centers_in_the_United_States")
fmt.Println("Attempting to find burn wards...")
if err != nil {
log.Fatal(err)
os.Exit(1)
}
defer response.Body.Close()
document, err := goquery.NewDocumentFromReader(response.Body)
if err != nil {
log.Fatal("Error loading HTTP response body. ", err)
}
document.Find("ul li a").Each(findBurnWards)
fmt.Println("Done...")
}
func findBurnWards(index int, element *goquery.Selection) {
val, exists := element.Attr("title")
if exists || val != "Wikipedia:Citation needed" {
fmt.Println(val)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment