爬取 Stackoverflow 100 萬條問答并簡(jiǎn)單分析

作為一個(gè)熱愛編程的大學(xué)生,怎么能不知道面向 stackoverflow 編程呢。

打開 stackoverflow 主頁,在 questions 頁面下選擇按 vote 排序,爬取前 20000 頁,每頁將問題數(shù)量設(shè)置為 50,共 1m 條,(實(shí)際上本來是想爬完 13m 條的,但 1m 條后面問題基本上都只有 1 個(gè)或 0 個(gè)回答,那就選取前 1m 就好吧)

實(shí)際上用數(shù)據(jù)庫去重后只有 999654 條問答信息

對(duì)爬取數(shù)據(jù)進(jìn)行簡(jiǎn)單分析

votes 分析

降序排列了 votes 數(shù),生成折線圖

Votes折線圖

2k 后的問題的 votes 數(shù)基本上就已經(jīng)在 400 以下了,接著后面的就基本上是貼地飛行了
votes 數(shù)最多 : Why is it faster to process a sorted array than an unsorted array?

votes 數(shù)的連續(xù)分布情況

votes甘特圖

可見最多的還是集中在 1-2K 之間,從 6k 開始基本上就斷層了

具體數(shù)據(jù)

description count
votes >= 500 1630
votes >= 400 2325
votes >= 300 3782
votes >= 200 7062
votes >= 100 19781

如果以 100 為分界線的話,會(huì)得到這樣的一個(gè)餅圖

pie_votes_1

大于 100 的連 %2 都不到

再來看看底層的數(shù)據(jù)

description count
1 <= votes <= 5 211804
6 <= votes <= 10 430935
11 <= votes <= 15 136647
16 <= votes <= 20 64541
votes <= 20 843927

可見 votes 小于 20 的,數(shù)量高達(dá) 84m
看看總體的比例吧

pie_votes_2

answers 分析

降序排列了 answers 數(shù),生成折線圖

answers折線圖

很明顯 3k 之后的 answers 數(shù)基本上就小于 20 了
answers 數(shù)最多: What is the best comment in source code you have ever encountered? [closed]

answers 數(shù)的連續(xù)分布情況

answers甘特圖

150 后也就斷層了,實(shí)際上能達(dá)到這樣的回答數(shù)極少

具體數(shù)據(jù)

description count
answers >= 5 218059
answers >= 10 34500
answers >= 20 3808
answers >= 30 968

大于 30 的確實(shí)少的可憐,看看總體情況

pie_answer_1

views 分析

降序排列了 views 數(shù),生成折線圖

views折線圖

最高達(dá)到了 4.5m,100000 以后的基本上就不足 28000 了
views 數(shù)最多: How to undo last commit(s) in Git?

views 數(shù)的連續(xù)分布情況

views甘特圖

具體數(shù)據(jù)

description count
views >= 5000 486466
views >= 10000 315576
views >= 20000 171873
views >= 50000 59363
views >= 100000 22224
views >= 200000 7030

大部分問答的 views 數(shù)還是集中在 20000 以內(nèi)
還是得看看總體分布

bubble_views

再看看 votes,views,answers 三者的散點(diǎn)圖對(duì)應(yīng)情況

votes - views

votes-views散點(diǎn)圖

votes - answers

votes-answers散點(diǎn)圖

views - answers

views-answers散點(diǎn)圖

總的來說,這三者對(duì)應(yīng)關(guān)系類似于一個(gè)金字塔。三個(gè)圖基本上都是左下角靠近原點(diǎn)的區(qū)域被填滿,也就是說絕對(duì)大部分的問題的 votes,answers 和 views 都是屬于最下層的。高質(zhì)量活躍的問題是處于金字塔頂端的。三者的最高數(shù)好像也沒特別明顯的對(duì)應(yīng)關(guān)系,且三者的最高數(shù)都不是同一個(gè)問題。

根據(jù)所有問題的 tags 提取出總量前 200 的關(guān)鍵詞(前 50 條如下),第 1 名是 c#,python 排在第 5

('c#', 94614),
('java', 93244),
('javascript', 76722),
('android', 69321),
('python', 62502),
('c++', 58173),
('php', 42596),
('ios', 37773),
('jquery', 37405),
('.net', 36180),
('html', 28536),
('css', 26174),
('c', 24699),
('objective-c', 23253),
('iphone', 22171),
('ruby-on-rails', 20143),
('sql', 19171),
('asp.net', 18060),
('mysql', 17559),
('ruby', 16397),
('r', 15670),
('git', 13139),
('linux', 13080),
('asp.net-mvc', 12857),
('angularjs', 12606),
('sql-server', 12473),
('node.js', 12212),
('django', 11576),
('arrays', 11006),
('algorithm', 10959),
('wpf', 10631),
('performance', 10619),
('xcode', 10613),
('string', 10426),
('windows', 10132),
('eclipse', 10117),
('scala', 9942),
('regex', 9685),
('multithreading', 9601),
('json', 9266),
('swift', 8950),
('c++11', 8939),
('haskell', 8823),
('osx', 8159),
('visual-studio', 8140),
('html5', 7627),
('database', 7567),
('xml', 7478),
('spring', 7464),
('unit-testing', 7253),
('bash', 6825)

這樣看好像不太直觀,所以就把它根據(jù)詞頻生成了詞云

詞云

因?yàn)槭怯?Python 寫的爬蟲,所以重點(diǎn)來分析下 Python 類的問答

votes 數(shù)前 10

answers 數(shù)前 10

views 數(shù)前 10

三者的前 10 中有 2 個(gè)問題是完全重疊的,分別是

Github 源碼

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容