import requests
from bs4 import BeautifulSoup
import pandas as pd
#下面是请求数据
url="https://www.163.com/" #设置请求网址为搜索网址
response=requests.get(url) #对163网站就行get请求并将请求结果赋值给response
response.encoding="GBK" #设置编码为GBK格式的
html=response.text #获取网页的html源代码并赋值给html
#下面是解析数据
soup=BeautifulSoup(html)
content=soup.findAll('div') #查找所有的div标签内容并赋值给content
print(content) #打印content
如果您觉得本文的内容对您的学习有所帮助:
关键字:
DIV