用于Python的JavaScript domapi、Html解析器和Web抓取库
dompy-parser的Python项目详细描述
<;p align='center'>;<;img src=“https://raw.githubusercontent.com/Anikeshpatel/dompy/master/docs/assets/logos/Group%205.png”/>;<;/p>; <;!-多姆比- 用于Python的JavaScript domapi、Html解析器和Python中的Web抓取工具
安装 `bash pip install dompy-parser `
基本API
`python
>>> from dompy import Document
>>> document = Document.fromURL('https://www.lipsum.com')
>>> document.title
'Lorem Ipsum - All the facts - Lipsum generator'
>>> elements = document.getElementsByTag('h3')
>>> len(elements)
5
>>> elements[0].innerHTML
'The standard Lorem Ipsum passage, used since the 1500s'
`
<;!-{/str>
`python >>> from dompy import DompyParser >>> document = DompyParser.parse('<div><h3color="blue"align="center">Abc</h3><h3>Xyz</h3></div>') >>> elements = document.getElementsByTag('h3') >>> len(elements) 2 >>> elements[0].innerHTML 'Abc' >>> elements[0].attributes {'color': 'blue', 'align': 'center'} ` __在
许可证 Dompy是gnugplv3.0授权的,如许可文件中所示。在
- 项目
标签: