爬取b站首页的 导航里的标题字 。练习

tech2022-12-17  113

爬取b站首页的 导航里的标题字 。练习 ,为啥有的‘’‘’‘"番剧”等词爬不下来?

import requests from bs4 import BeautifulSoup url = 'https://www.bilibili.com/' response = requests.get(url) #print(response) html = response.text #print(html) soup = BeautifulSoup(html,'html.parser') #datas = soup.find('ul',class_="con").text #print(datas) datas2 = soup.find('div',class_="channel-menu-itnl report-wrap-module") #print(datas2) for i in datas2: tou_name = i.find(class_="name").text print(tou_name)

最新回复(0)