Beautiful Soup 示例解析html文件(python)

来源:互联网 发布:雇一次网络水军多少钱 编辑:程序博客网 时间:2024/05/22 03:27

1.理解html文件格式和内容

大框架

<html>

<head>

.....

</head>

<body>

......

<body>

</html>

2.安装Beautiful Soup 

3.安装lxml

from bs4 import BeautifulSoup
import re
soup = BeautifulSoup(open('E://0000bee3dab9ec4085b36c8f99b34289.html'),'html.parser')
for string in soup.stripped_strings:
    print(repr(string))

4.进一步处理


0 0
原创粉丝点击