{"id":22951357,"url":"https://github.com/calsranna/html_parser_plus","last_synced_at":"2025-07-21T12:35:08.568Z","repository":{"id":61976084,"uuid":"554662089","full_name":"CalsRanna/html_parser_plus","owner":"CalsRanna","description":"Use custom rule to parse html document","archived":false,"fork":false,"pushed_at":"2023-12-10T20:16:35.000Z","size":22,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T22:48:36.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CalsRanna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-10-20T07:14:36.000Z","updated_at":"2022-10-20T08:00:02.000Z","dependencies_parsed_at":"2022-10-24T14:00:33.433Z","dependency_job_id":"e701daa9-b96f-4b68-ad0e-785b45c7dba9","html_url":"https://github.com/CalsRanna/html_parser_plus","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"c170ab01b6941da62e5e8bc537d9937adf3a38d1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CalsRanna/html_parser_plus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CalsRanna%2Fhtml_parser_plus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CalsRanna%2Fhtml_parser_plus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CalsRanna%2Fhtml_parser_plus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CalsRanna%2Fhtml_parser_plus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CalsRanna","download_url":"https://codeload.github.com/CalsRanna/html_parser_plus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CalsRanna%2Fhtml_parser_plus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266303292,"owners_count":23908339,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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-12-14T15:15:12.780Z","updated_at":"2025-07-21T12:35:08.536Z","avatar_url":"https://github.com/CalsRanna.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Html Parser\n\nThis is a package use to parse html document into nodes and string.\n\n## Install\n\n```bash\nflutter pub add html_parser_plus\n```\n\n## Getting started\n\n```dart\nimport 'package:html_parser_plus/html_parser_plus.dart';\n\nvoid main() {\n  const String htmlString = '''\n      \u003chtml lang=\"en\"\u003e\n      \u003cbody\u003e\n      \u003cdiv\u003e\u003ca href='https://github.com/simonkimi'\u003eauthor\u003c/a\u003e\u003c/div\u003e\n      \u003cdiv class=\"head\"\u003ediv head\u003c/div\u003e\n      \u003cdiv class=\"container\"\u003e\n          \u003ctable\u003e\n              \u003ctbody\u003e\n                \u003ctr\u003e\n                    \u003ctd id=\"td1\" class=\"first1\"\u003e1\u003c/td\u003e\n                    \u003ctd id=\"td2\" class=\"first1\"\u003e2\u003c/td\u003e\n                    \u003ctd id=\"td3\" class=\"first2\"\u003e3\u003c/td\u003e\n                    \u003ctd id=\"td4\" class=\"first2 form\"\u003e4\u003c/td\u003e\n\n                    \u003ctd id=\"td5\" class=\"second1\"\u003eone\u003c/td\u003e\n                    \u003ctd id=\"td6\" class=\"second1\"\u003etwo\u003c/td\u003e\n                    \u003ctd id=\"td7\" class=\"second2\"\u003ethree\u003c/td\u003e\n                    \u003ctd id=\"td8\" class=\"second2\"\u003efour\u003c/td\u003e\n                \u003c/tr\u003e\n              \u003c/tbody\u003e\n          \u003c/table\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"end\"\u003eend\u003c/div\u003e\n      \u003c/body\u003e\n      \u003c/html\u003e\n      ''';\n  final parser = HtmlParser();\n  var node = parser.parse(htmlString);\n  parser.query(node, '//div/a@text');\n  parser.query(\n    node,\n    '//div/a/@href|dart.replace(https://,)|dart.substring(0,10)',\n  );\n  parser.queryNodes(node, '//tr/td|dart.sublist(0,2)');\n\n  const String jsonString = '''\n      {\"author\":\"Cals Ranna\",\"website\":\"https://github.com/CalsRanna\",\"books\":[{\"name\":\"Hello\"},{\"name\":\"World\"},{\"name\":\"!\"}]}\n      ''';\n\n  node = parser.parse(jsonString);\n  parser.query(node, r'$.author');\n  parser.query(\n    node,\n    r'$.website|dart.replace(https://,)|dart.substring(0,10)',\n  );\n  parser.queryNodes(node, r'$.books|dart.sublist(0,2)');\n}\n\n\n```\n\n## Usage\n\nSo far, we have supported:\n\n- some **xpath** syntax by **xpath_selector**\n- almost all **jsonPath** syntax by **json_path**\n\nAnd seven supported functions list below:\n\n- **sublist** for `List\u003cHtmlParserNode\u003e`\n- **replace** for `String`\n- **replaceFirst** for `String`\n- **replaceRegExp** for `String`\n- **substring** for `String`\n- **trim** for `String`\n- **interpolate** for `String`, use `{{string}}` to indicate the piped value\n- **match** for `String`\n\n\u003e You should know that in the function, the params **CAN NOT** be wrapped by **'** or **\"**.\n\n\u003e And the rule is like **//div/a@text|dart.replace(Author,)|dart.replace( ,)|dart.interpolate(作者：{{string}})**.\n\n\u003e Use **|** to pipe all rules.\n\n## Legacy\n\n- `function:` will be replaced by `dart.` in the future.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalsranna%2Fhtml_parser_plus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalsranna%2Fhtml_parser_plus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalsranna%2Fhtml_parser_plus/lists"}