{"id":16885129,"url":"https://github.com/ericchiang/scrape","last_synced_at":"2026-05-11T16:34:50.499Z","repository":{"id":145910107,"uuid":"49787471","full_name":"ericchiang/scrape","owner":"ericchiang","description":null,"archived":false,"fork":false,"pushed_at":"2016-01-16T19:25:54.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T05:45:16.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericchiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-16T19:22:00.000Z","updated_at":"2016-01-22T17:36:23.000Z","dependencies_parsed_at":"2023-04-18T07:31:29.359Z","dependency_job_id":null,"html_url":"https://github.com/ericchiang/scrape","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ericchiang/scrape","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericchiang%2Fscrape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericchiang%2Fscrape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericchiang%2Fscrape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericchiang%2Fscrape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericchiang","download_url":"https://codeload.github.com/ericchiang/scrape/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericchiang%2Fscrape/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32903461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"online","status_checked_at":"2026-05-11T02:00:05.975Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T16:33:28.482Z","updated_at":"2026-05-11T16:34:50.473Z","avatar_url":"https://github.com/ericchiang.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scrape\n\nA simple, higher level interface for Go web scraping.\n\n[![GoDoc](https://godoc.org/github.com/ericchiang/scrape?status.svg)](https://godoc.org/github.com/ericchiang/scrape)\n\n## Sample\n\nScrape defines traversal functions like `Find` and `FindAll` while attempting\nto be generic. It also defines convenience functions such as `Attr` and `Text`.\n\n```go\n// Parse the page\nroot, err := html.Parse(resp.Body)\nif err != nil {\n    // handle error\n}\n// Search for the title\ntitle, ok := scrape.Find(root, scrape.ByTag(atom.Title))\nif ok {\n    // Print the title\n    fmt.Println(scrape.Text(title))\n}\n```\n\n## A full example: Scraping Hacker News\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/ericchiang/scrape\"\n\t\"golang.org/x/net/html\"\n\t\"golang.org/x/net/html/atom\"\n)\n\nfunc main() {\n\t// request and parse the front page\n\tresp, err := http.Get(\"https://news.ycombinator.com/\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\troot, err := html.Parse(resp.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// define a matcher\n\tmatcher := func(n *html.Node) bool {\n\t\t// must check for nil values\n\t\tif n.DataAtom == atom.A \u0026\u0026 n.Parent != nil \u0026\u0026 n.Parent.Parent != nil {\n\t\t\treturn scrape.Attr(n.Parent.Parent, \"class\") == \"athing\"\n\t\t}\n\t\treturn false\n\t}\n\t// grab all articles and print them\n\tarticles := scrape.FindAll(root, matcher)\n\tfor i, article := range articles {\n\t\tfmt.Printf(\"%2d %s (%s)\\n\", i, scrape.Text(article), scrape.Attr(article, \"href\"))\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericchiang%2Fscrape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericchiang%2Fscrape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericchiang%2Fscrape/lists"}