{"id":17087913,"url":"https://github.com/lian-yue/dom","last_synced_at":"2026-05-08T04:15:47.881Z","repository":{"id":33149191,"uuid":"36789072","full_name":"lian-yue/dom","owner":"lian-yue","description":"php  html  document node parse  css level3","archived":false,"fork":false,"pushed_at":"2015-07-25T12:24:27.000Z","size":224,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T15:16:34.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","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/lian-yue.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":"2015-06-03T08:04:47.000Z","updated_at":"2024-10-25T16:02:29.000Z","dependencies_parsed_at":"2022-07-08T07:32:46.662Z","dependency_job_id":null,"html_url":"https://github.com/lian-yue/dom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lian-yue/dom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lian-yue%2Fdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lian-yue%2Fdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lian-yue%2Fdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lian-yue%2Fdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lian-yue","download_url":"https://codeload.github.com/lian-yue/dom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lian-yue%2Fdom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268337938,"owners_count":24234538,"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-08-02T02:00:12.353Z","response_time":74,"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-14T13:35:24.001Z","updated_at":"2026-05-08T04:15:42.847Z","avatar_url":"https://github.com/lian-yue.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dom\n\n\n### test\n\t\u003c?php\n\n\terror_reporting(E_ALL);\n\tset_time_limit(3);\n\n\trequire_once  __DIR__ . '/Node.php';\n\trequire_once  __DIR__ . '/Style/Base.php';\n\trequire_once  __DIR__ . '/Style/Document.php';\n\trequire_once  __DIR__ . '/Style/Media.php';\n\trequire_once  __DIR__ . '/Style/MediaCondition.php';\n\trequire_once  __DIR__ . '/Style/Rule.php';\n\trequire_once  __DIR__ . '/Style/Selectors.php';\n\trequire_once  __DIR__ . '/Style/Supports.php';\n\n\n\n\t// html  解析\n\t$contents = file_get_contents(__DIR__ . '/html.html');\n\n\t$node = new DOM\\Node($contents);\n\n\t// 格式化的\n\techo $node-\u003eformat(true);\n\n\t// 不格式化的\n\techo $node;\n\n\t// 选择器\n\n\n\t// 返回 node 对象的\n\t//  按照id 选择\n\t$node-\u003egetElementById('ID');\n\n\t// css选择器 选择一个\n\t$node-\u003equerySelector('css选择器');\n\n\n\t// 返回数组的\n\n\t// 按照 class 选择\n\t$node-\u003egetElementsByClassName('class');\n\n\t// 按照 name 选择\n\t$node-\u003egetElementsByName('class');\n\n\t//  按照标签名选择\n\t$node-\u003egetElementsByTagName('tagname');\n\n\n\t// css选择器 选择所有\n\t$node-\u003equerySelectorAll('div.qq#xx[attr=\"xx\"]:has(img)');\n\n\n\n\n\n\n\n\t//  style 解析\n\t$contents = file_get_contents(__DIR__ . '/style.css');\n\n\t$rule = new DOM\\Style\\Rule($contents);\n\n\t// 格式化的\n\techo $node-\u003eformat(true);\n\n\t// 不格式化的\n\techo $node;\n\n\n\n\n\n\n\t\n\t\n\t\n\t// 过滤数据演示\n\n\t// 创建style 过滤 保留 属性 content 开头的前缀  #content-  .content- 开头的保留\n\t$filterStyle = new DOM\\Filter\\Style('content-');\n\t\n\t// 创建标签过滤 传入了filterStyle就允许style 标签\n\t$filterTags = new DOM\\Filter\\Tags($filterStyle);\n\t\n\t\n\t// 创建属性过滤  传入了filterStyle就允许style 属性\n\t$filterAttributes = new DOM\\Filter\\Attributes($filterStyle);\n\t\n\t\n\t/// 解析 dom\n\t$node = new DOM\\Node($contents);\n\t\n\t// 过滤标签\n\t$filterTags($node);\n\t\n\t// 过滤属性\n\t$filterAttributes($node);\n\t\n\t// 格式化并输出\n\techo $node-\u003eformat(true);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t?\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flian-yue%2Fdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flian-yue%2Fdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flian-yue%2Fdom/lists"}