Skip to content

Instantly share code, notes, and snippets.

@gotgithub
gotgithub / countdown.rb
Created September 8, 2011 07:46
Calculate the countdown for the meeting of the party.
#!/usr/bin/ruby
# Calculate the countdown for the meeting of the party.
require 'Date'
days=(DateTime.new(2012,10,15)-DateTime.now).ceil
if days >= 0
puts "Maybe #{days} days left."
else
puts "Passed for #{days.abs} days."
@eagleon
eagleon / 实时QPS
Last active September 10, 2019 06:12
实时QPS
某个时刻的实时qps监控:
tail /var/log/nginx/2012-08-25-taobao-access_log -f --pid=19139|grep "`date +%Y:%m:%d:%T`"|wc -l;
统计10秒中的总qps:
tail /var/log/nginx/2012-08-25-taobao-access_log -f -s 10 --pid=19139|wc -l
统计10秒中的平均qps:
echo "`/var/log/nginx/2012-08-25-taobao-access_log -f -s 10 --pid=19139|wc -l`/10"|bc
@zhaokuohaha
zhaokuohaha / Robots协议和robots.txt解读.md
Last active June 15, 2023 05:38
robots.txt基本语法, 以及robots协议的各家搜索引擎实现。

文件简介

简单的说 Robot 协议是用于告诉网络爬虫(主要是搜索引擎爬虫)本域名下的网页中, 那些部分是不应该爬取的,具体来说就是在网站的域名根目录下添加一份robots.txt文件, 并在文件中声明对应的规则. 由于 Url 对大小写敏感, 所以 robots.txt 文件名要求全部小写.

搜索引擎爬虫在爬取一个网站时, 首先检查是否存在 robots.txt 文件, 如果存在, 则在爬取该网站下其他网页时, 应遵循文件所定义的范围进行爬取.

需要注意的是 Robots 协议是一个共同遵循的"道德约定", 但是不具有法律效应, 同时也不保证所有搜索引擎都会遵守这个约定

内容和语法