Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 美丽的汤:提取H2标记之间的数据_Python_Web Scraping_Beautifulsoup - Fatal编程技术网

Python 美丽的汤:提取H2标记之间的数据

Python 美丽的汤:提取H2标记之间的数据,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我有一个html文本如下 1。python 通过使用靓汤,我们如何提取1。Pythontext 我正在努力 data=[1.Python, 2.HTML] 对于数据中的项目: text=item.findAll('h2') 打印(text.get_text()) 非常感谢您的建议。我已删除项。findAll('h2')并修改如下 for item in data: print(item.get_text()) 现在很好用

我有一个html文本如下

1。python
通过使用靓汤,我们如何提取
1。Python
text

我正在努力

data=[1.Python,
2.HTML]
对于数据中的项目:
text=item.findAll('h2')
打印(text.get_text())

非常感谢您的建议。

我已删除
项。findAll('h2')
并修改如下

for item in data:
    print(item.get_text())
现在很好用