python ertee HTML
时间: 2023-10-15 17:31:24 浏览: 44
在Python中,使用lxml库的etree.HTML()方法可以将HTML代码转换为XML格式的语法。例如,下面是一个示例代码:
```python
from bs4 import BeautifulSoup
html = ''' <p class='info-list'> <a class='name'>text1</a> <a class='name'>text2</a> <a class='name'>text3</a> <a class='name'>text4</a> </p> '''
soup = BeautifulSoup(html, 'lxml')
texts = soup.find('p', class_='info-list')
print(texts.contents<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Python3 爬虫](https://blog.csdn.net/dayuquan6226/article/details/101402548)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [python爬虫xpath的语法](https://blog.csdn.net/l277691507/article/details/52162720)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)