作為一個(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
- 6162 : What does the “yield” keyword do in Python?
- 3529 : What is a metaclass in Python?
- 3098 : How do I check whether a file exists using Python?
- 3035 : Does Python have a ternary conditional operator?
- 2620 : Calling an external command in Python
- 2605 : What does if name == “main”: do?
- 2194 : How to merge two Python dictionaries in a single expression?
- 2123 : Sort a Python dictionary by value
- 2058 : How to make a chain of function decorators?
- 1984 : How to check if a directory exists and create it if necessary?
answers 數(shù)前 10
- 191 : Hidden features of Python [closed]
- 87 : Best ways to teach a beginner to program? [closed]
- 55 : Favorite Django Tips & Features?
- 50 : How do you split a list into evenly sized chunks?
- 44 : Calling an external command in Python
- 43 : How can I represent an 'Enum' in Python?
- 38 : How to merge two Python dictionaries in a single expressions
- 38 : Finding local IP addresses using Python's stdlib
- 37 : Reverse a string in python without using reversed or [::-1]
- 37 : How do I check whether a file exists using Python?
views 數(shù)前 10
- 2121621 : Parse String to Float or Int
- 1905938 : Using global variables in a function other than the one that created them
- 1888666 : How do I check whether a file exists using Python?
- 1827126 : Calling an external command in Python
- 1699574 : Converting integer to string in Python?
- 1686230 : How do I read a file line-by-line into a list?
- 1682307 : Iterating over dictionaries using 'for' loops in Python
- 1569205 : How to get the size of a list
- 1554755 : How do I install pip on Windows?
- 1515505 : Finding the index of an item given a list containing it in Python
三者的前 10 中有 2 個(gè)問題是完全重疊的,分別是
Github 源碼
- 爬取 Stackoverflow100 萬條問答
- 歡迎 Fork 和 Star