{"id":19769424,"url":"https://github.com/goplus/hdq","last_synced_at":"2025-04-30T17:31:15.386Z","repository":{"id":37440108,"uuid":"395527973","full_name":"goplus/hdq","owner":"goplus","description":"HTML DOM Query Language for Go+","archived":false,"fork":false,"pushed_at":"2024-04-15T14:18:28.000Z","size":125,"stargazers_count":38,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-20T09:16:03.611Z","etag":null,"topics":["dom-query","go","golang","gop","goplus","hdq","html","query-language"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goplus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-13T05:12:04.000Z","updated_at":"2024-05-07T12:28:57.246Z","dependencies_parsed_at":"2023-11-14T04:27:44.341Z","dependency_job_id":"5bd3011c-de54-45ad-a174-17c7e25882b3","html_url":"https://github.com/goplus/hdq","commit_stats":null,"previous_names":["qiniu/hdq"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fhdq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fhdq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fhdq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goplus%2Fhdq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goplus","download_url":"https://codeload.github.com/goplus/hdq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224219736,"owners_count":17275476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dom-query","go","golang","gop","goplus","hdq","html","query-language"],"created_at":"2024-11-12T04:43:06.032Z","updated_at":"2024-11-12T04:43:06.667Z","avatar_url":"https://github.com/goplus.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"hdq - HTML DOM Query Language for Go+\n========\n\n[![Build Status](https://github.com/goplus/hdq/actions/workflows/go.yml/badge.svg)](https://github.com/goplus/hdq/actions/workflows/go.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/goplus/hdq)](https://goreportcard.com/report/github.com/goplus/hdq)\n[![GitHub release](https://img.shields.io/github/v/tag/goplus/hdq.svg?label=release)](https://github.com/goplus/hdq/releases)\n[![Coverage Status](https://codecov.io/gh/goplus/hdq/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/hdq)\n[![Language](https://img.shields.io/badge/language-Go+-blue.svg)](https://github.com/goplus/gop)\n[![GoDoc](https://img.shields.io/badge/godoc-reference-teal.svg)](https://pkg.go.dev/mod/github.com/goplus/hdq)\n\n## Summary about hdq\n\nhdq is a Go+ package for processing HTML documents.\n\n## Tutorials\n\n### Collect links of a html page\n\nHow to collect all links of a html page? If you use `hdq`, it is very easy.\n\n```go\nimport \"github.com/goplus/hdq\"\n\nfunc links(url any) []string {\n\tdoc := hdq.Source(url)\n\treturn [link for a \u003c- doc.any.a if link := a.href?:\"\"; link != \"\"]\n}\n```\n\nAt first, we call `hdq.Source(url)` to create a `node set` named `doc`. `doc` is a node set which only contains one node, the root node.\n\nThen, select all `a` elements by `doc.any.a`. Here `doc.any` means all nodes in the html document.\n\nThen, we visit all these `a` elements, get `href` attribute value and assign it to the variable `link`. If link is not empty, collect it.\n\nAt last, we return all collected links. Goto [tutorial/01-Links](tutorial/01-Links/links.gop) to get the full source code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoplus%2Fhdq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoplus%2Fhdq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoplus%2Fhdq/lists"}