bs4解析数据

bs4解析数据

#encoding=utf8

import requests
import re
# from lxml import etree
from bs4 import BeautifulSoup

#设置用户标识
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36'
}
url='https://www.1905.com/vod/top/lst/'
# 发送请求
html = requests.get(url,headers=header)
# print(html.text)
# 处理数据
# 1.创建BeautifulSoup解析工具,选择解析器进行解析
bhtml=BeautifulSoup(html.text,'lxml')
# 2.通过css选择器搜索对应节点
result= bhtml.select('dt[class="li03 oh"] a')
for x in result:
    print(x.get_text())




上一篇:问答系统搭建


下一篇:理解maven的parent标签里面的relativePath