{"id":20994951,"url":"https://github.com/elliotgao2/htmlparsing","last_synced_at":"2025-05-14T21:30:57.003Z","repository":{"id":62569605,"uuid":"122949644","full_name":"elliotgao2/htmlparsing","owner":"elliotgao2","description":"No pain HTML parsing library. ","archived":false,"fork":false,"pushed_at":"2018-04-02T09:19:56.000Z","size":18,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T23:32:40.532Z","etag":null,"topics":["css","html","markdown","parse","xpath"],"latest_commit_sha":null,"homepage":"","language":"Python","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/elliotgao2.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":"2018-02-26T09:57:15.000Z","updated_at":"2024-07-16T14:47:25.000Z","dependencies_parsed_at":"2022-11-03T17:01:08.204Z","dependency_job_id":null,"html_url":"https://github.com/elliotgao2/htmlparsing","commit_stats":null,"previous_names":["gaojiuli/htmlparsing"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotgao2%2Fhtmlparsing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotgao2%2Fhtmlparsing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotgao2%2Fhtmlparsing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elliotgao2%2Fhtmlparsing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elliotgao2","download_url":"https://codeload.github.com/elliotgao2/htmlparsing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254230802,"owners_count":22036246,"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":["css","html","markdown","parse","xpath"],"created_at":"2024-11-19T07:20:42.020Z","updated_at":"2025-05-14T21:30:53.967Z","avatar_url":"https://github.com/elliotgao2.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTML Parsing\n\nNo Pain HTML parsing library.\n\n\n## Installation\n\n```python\npip install htmlparsing\n```\n\n## Usage\n\n\n### Parse list\n\n```python\nimport requests\nfrom htmlparsing import Element, HTMLParsing, Text, Attr, Parse, HTML, Markdown\n\nurl = 'https://news.ycombinator.com/'\nr = requests.get(url)\narticle_list = HTMLParsing(r.text).list('.athing', {'title': Text('a.storylink'), # css selector\n                                                    'link': Attr('a.storylink', 'href')})\nprint(article_list)\n\n```\n### Parse detail\n\n```python\nimport requests\nfrom htmlparsing import Element, HTMLParsing, Text, Attr, Parse\n\nurl = 'https://news.ycombinator.com/item?id=16476454'\nr = requests.get(url)\narticle_detail = HTMLParsing(r.text).detail({'title': Text('a.storylink'),\n                                             'points': Parse('span.score', '\u003e{} points'),\n                                             'link': Attr('a.storylink', 'href')})\nprint(article_detail)\n```\n\n### Element\n\n```python\n\nimport requests\nfrom htmlparsing import Element\nurl = 'https://python.org/'\nr = requests.get(url)\n\ne = Element(text=r.text)\ne.links\ne.absolute_links\ne.xpath('//a')[0].attrs\ne.xpath('//a')[0].attrs.title\ne.css('a')[0].attrs\ne.parse('\u003ca href=\"#content\" title=\"Skip to content\"\u003e{}\u003c/a\u003e')\ne.css('a')[5].text\ne.css('a')[5].html\ne.css('a')[5].markdown\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotgao2%2Fhtmlparsing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felliotgao2%2Fhtmlparsing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felliotgao2%2Fhtmlparsing/lists"}