爬取微博热搜

1.主题式网络爬虫名称  爬取微博热搜
2.主题式网络爬虫爬取的内容与数据特征分析   爬取新浪网热搜排行榜、热度
3.主题式网络爬虫设计方案概述(包括实现思路与技术难点)

通过requests,beautifulsoup, pandas,matplotlib.pyplot等等进行网页爬取,数据提取分析,数据可视化

 

import requests
from bs4 import BeautifulSoup
import pandas as pd
url='https://s.weibo.com/top/summary?cate=realtimehot'
headers={'User-Agent':url}
r=requests.get(url,headers=headers)
#print(r.text)
soup=BeautifulSoup(r.content,'html.parser')
title=soup.find_all("td",{"class":"al"})
for title in title[:10]:
    title.get_text()
sales=soup.find_all("td")
for sales in sales[:40]:
    print(sales.get_text())
爬取微博热搜_第1张图片 爬取微博热搜_第2张图片 爬取微博热搜_第3张图片
print('\n====各列是否有缺失值情况如下:====')
print(df.isnull())     #统计空值情况
print(df.duplicated()) #查找重复值
print(df.isna().head()) 
print(df.describe())   #描述数据

  爬取微博热搜_第4张图片爬取微博热搜_第5张图片

绘图

爬取微博热搜_第6张图片爬取微博热搜_第7张图片

总结

网络爬虫能帮助我们将数据简单化,可视化,更好的分析数据


 

  

 

你可能感兴趣的:(爬取微博热搜)