量化Hacker News 中50天的数据 Quantifying Hacker News with 50 days of data
Quantifying Hacker News
I thought it would be fun to analyze the activity on one of my favorite sources of interesting links and information, Hacker News. My source of data is a script I've set up some time in August that downloads HN (the Front page and the New stories page) every minute. We will be interested in visualizing the stories as they get upvoted during the day, figuring out which domains/users are most popular, what topics are most popular, and the best time to post a story. I'm making all my data and code (Python data collection scripts + IPython Notebook for analysis) available in case you'd like to carry out a similar analysis.
Data collection protocol
I set up a very simple python script that scrapes the HN front page and the new stories page every minute. A single day of data begins at 4am (PST) and ends at 4am the next day. The .html files are saved compressed as gzipped pickles and one day occupies roughly 10mb in this format. I had bring down my machine for a few days a few times so there are some gaps in the data, but in the end we get 47 days of data from period between August 22 and October 30.
Raw HTML data parsing
The parsing Python script uses BeautifulSoup to convert the raw HTML into a more structured JSON. This script was by the way by no means simple to write -- HN is based on unstructured tables and I had to discover many strange edge cases in its behavior along the way. At the end I ended up with a 100-line ugliest-parsing-function-ever (really, I'm not proud of it) but it works and outputs something like the following for a single story at a specific snapshot:
{
'domain': u'play.google.com', 'title': u'Nexus 5',
'url': u'https://play.google.com/store/devices/details?id=nexus_5_black_16gb',
'num_comments': 42, 'rank': 1, 'points': 65,
'user': u'sonier', 'minutes_ago': 39, 'id': u'6648519'
}
We get 60 such entries every minute (30 for front page and 30 for new page) and these are again all saved to disk. We are now ready to bring out the IPython Notebook and get to the juicy analysis!
The Analysis: Detailed analysis
Head over to the IPython Notebook rendered as HTML for the analysis:
Note: I had the entire dataset and .ipynb Ipython Notebook source available for download but recently took it down to save space on my host (sorry).
from: http://karpathy.github.io/2013/11/27/quantifying-hacker-news/
量化Hacker News 中50天的数据 Quantifying Hacker News with 50 days of data的更多相关文章
- Hi3559AV100 NNIE开发(5)mobilefacenet.wk仿真成功量化及与CNN_convert_bin_and_print_featuremap.py输出中间层数据对比过程
前面随笔给出了NNIE开发的基本知识,下面几篇随笔将着重于Mobilefacenet NNIE开发,实现mobilefacenet.wk的chip版本,并在Hi3559AV100上实现mobilefa ...
- 分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)
分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tab ...
- for循环往Oracle中插入n条数据,主键自增
1.主键自增实现方法:http://www.cnblogs.com/Donnnnnn/p/5959871.html 2.for循环往Oracle中插入n条数据 BEGIN .. loop insert ...
- 转:SQL SERVER数据库中实现快速的数据提取和数据分页
探讨如何在有着1000万条数据的MS SQL SERVER数据库中实现快速的数据提取和数据分页.以下代码说明了我们实例中数据库的“红头文件”一表的部分数据结构: CREATE TABLE [dbo]. ...
- SQL Server 2008中新增的变更数据捕获(CDC)和更改跟踪
来源:http://www.cnblogs.com/downmoon/archive/2012/04/10/2439462.html 本文主要介绍SQL Server中记录数据变更的四个方法:触发器 ...
- 在JSP页面中输出JSON格式数据
JSON-taglib是一套使在JSP页面中输出JSON格式数据的标签库. JSON-taglib主页: http://json-taglib.sourceforge.net/index.html J ...
- (转)分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间)
分享一个SQLSERVER脚本(计算数据库中各个表的数据量和每行记录所占用空间) 很多时候我们都需要计算数据库中各个表的数据量和每行记录所占用空间 这里共享一个脚本 CREATE TABLE #tab ...
- Android编程中的5种数据存储方式
Android编程中的5种数据存储方式 作者:牛奶.不加糖 字体:[增加 减小] 类型:转载 时间:2015-12-03我要评论 这篇文章主要介绍了Android编程中的5种数据存储方式,结合实例形式 ...
- 另类爬虫:从PDF文件中爬取表格数据
简介 本文将展示一个稍微不一样点的爬虫. 以往我们的爬虫都是从网络上爬取数据,因为网页一般用HTML,CSS,JavaScript代码写成,因此,有大量成熟的技术来爬取网页中的各种数据.这次, ...
随机推荐
- 使用IE浏览器下载时候窗口一闪而过
使用IE浏览器下载东西时,窗口一闪而过,那么这个问题怎么处理呢? 解决办法: 1.按住ctrl键进行下载 2.浏览器>工具>internet选项>安全自定义级别>下载文件自动提 ...
- Sql Server 常用自定义函数
-- select * from [dbo].[SplitToTable]('ADSF','|') -- 分解字符串 ALTER FUNCTION [dbo].[SplitToTable] ( @Sp ...
- iTween基础之Rotate(旋转角度)
一.基础介绍:二.基础属性 原文地址 :http://blog.csdn.net/dingkun520wy/article/details/50696489 一.基础介绍 RotateTo:旋转游戏物 ...
- axure7.0 汉化包下载
下载地址:http://files.cnblogs.com/files/feijian/axure7.0%E4%B8%AD%E6%96%87%E8%AF%AD%E8%A8%80%E6%B1%89%E5 ...
- org.apache.commons.dbutils.QueryRunner 执行sqlserver的存储过程
执行不带输出参数的存储过程与 执行普通update sql没有什么区别,直接调用即可: 示例代码: public Boolean startResidentialInfoStatistics(Str ...
- JS中删除字符串中的空格
问题描述: 在进行字符串操作时,由于字符串中存在较多的空格,因此需要考虑取消字符串中的空格 问题解决: (1)删除字符串中的前导空格(字符串的前面的空格): 注意:这里使用 ...
- make -f dc_debug.mak 提示错误"/usr/bin/ld:can not find -l***"解决办法
在公司不同服务器上"make -f ***"程序的时候,有的服务器可以编译通过,有的却提示"/usr/bin/ld:can not find -l***"的错误 ...
- httpclient 人人网
登录的站点是3g.renren.com 因为是手机人人, 页面比较简单 首先用HttpGet取出"http://3g.renren.com"的html代码, 是用Jsoup解析出登 ...
- POJ 3126 Prime Path(BFS求“最短路”)
题意:给出两个四位数的素数,按如下规则变换,使得将第一位数变换成第二位数的花费最少,输出最少值,否则输出0. 每次只能变换四位数的其中一位数,使得变换后的数也为素数,每次变换都需要1英镑(即使换上的数 ...
- Oracle函数+for循环
create or replace function FilterMinganci(str in varchar) return varchar2 is filterWorld varchar2(10 ...