python小白,純屬來玩的(狗頭)requests
bs4jieba
wordcloud
imageio
matplotlib
**直接貼上了,自行研究
import requests
import time
from bs4 import beautifulsoup
import json
def get_html(url):
headers =
r = requests.get(url, timeout=30,headers=headers)
r.raise_for_status()
r.endcodding = 'utf-8'
return r.text
def get_content(url):
comments =
html = get_html(url)
try:
s=json.loads(html)
except:
print("jsonload error")
num=len(s['data']['replies'])
i=0while i這個需要先有個,隨便網上找,然後和py放在乙個資料夾下。
mywc.show_wc()
還是那句話,冰冰真可愛(狗頭)
爬取B站「冰冰vlog 001「評論 做詞云
python小白,純屬來玩的 狗頭 requests bs4jieba wordcloud imageio matplotlib 直接貼上了,自行研究 import requests import time from bs4 import beautifulsoup import json defg...
用Python爬取王冰冰vlog彈幕並製作詞云
最近的 瓜 多到我們措手不及,可謂是 熱點不斷 作為程式設計師,我們還可能隨時為此而加班。1.網頁解析 網頁結構可能隨時會發生變化。2.python第三方api 可能會有維護跟不上的問題。經過簡單對比,我選擇第一種方法。獲取資訊 defget page self try 延時操作,防止太快爬取 ti...
爬取B站彈幕
最近幾天學習爬蟲,便爬取了b站的彈幕,本篇博文記錄的是爬取彈幕的方法一,近期會更新方法二。下面是流程 點開這個包是這個形式的 這裡面就有明文的彈幕,但通過requests獲得的response是經過utf 8編碼加密過的,想要獲得彈幕內容還要解密。下面附 from bs4 import beauti...