http库测试工具---httpbin

(图片来自互联网) 如果一个人想学习爬虫技术,我会首先推荐他学会使用httpbin! httpbin(官网|github)是一个很不错测试工具,你可以放心大胆的黑他,而不用担心他报复你。他有点像一个蜜罐,时刻等待着你的光临,然后根据你的请求,给你返回你想要的东西 ...

June 27, 2015 · 1 min · Me

PHP天坑总结

PHP天坑你懂得,不断总结中。。。 ...

June 27, 2015 · 2 min · Me

MAC下快速安装PHP

请安装Homebrew先 # 添加源 brew tap josegonzalez/homebrew-php # 一键安装php各个版本 brew install php54 php54-mcrypt brew install php55 php55-xdebug brew install php56

June 26, 2015 · 1 min · Me

简单socket编程1

(图片来自互联网) 说到socket,学过网络基础的人都听过,他是TCP/IP的抽象,他是网络世界的入口,它无处不在。 学会了socket编程,就意味着能够更深层次的控制你的流量,之后再看python的urllib*或php的curl,简直就是小儿科! ...

June 24, 2015 · 2 min · Me

近距离接触HTTP协议

(图片来自WIKI) 超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。我们打开浏览器输入网址www.google.com,不对!刚才那个是一个不存在的网址,我们还是用www.phpgao.com为例吧。我们(客户端)将老高的域名输入浏览器,浏览器就会为我们呈现老高的网页,首先我们能确定作为客户端,在此期间必定与老高的服务器发生了某种关系!但是具体发送了什么呢?作为一名WEB开发人员,这是我们必须知道的。 ...

June 24, 2015 · 2 min · Me

python中的cookielib的使用方法

(图片来自互联网) cookielib是一个自动处理cookies的模块,如果我们在使用爬虫等技术的时候需要保存cookie,那么cookielib会让你事半功倍!他最常见的搭档模块就是python下的urllib和request。 但是老高在使用cookielib的时候总是碰到这样那样的问题,在查看cookielib的源码后,有所感悟。 ...

June 21, 2015 · 2 min · Me

使用Privoxy将socks5代理转为http代理

大家都知道shadowsocks只提供了SOCKS5的代理,而没有提供http代理,而很多软件仅提供了http代理的支持,比如老高需要使用shell命令行扶墙,或者使用git同步android的源代码,再或者更新android SDK,该怎么办呢? 老高在此介绍一个软件Privoxy,它可以作为代理的代理,为我们解决上述问题! Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk. Privoxy has a flexible configuration and can be customized to suit individual needs and tastes. It has application for both stand-alone systems and multi-user networks. 由介绍看来,privoxy的功能可远远不止http代理这么简单! ...

June 19, 2015 · 2 min · Me

新主题基于Bootstrap3

大家应该注意到了,老高花了两天时间匆忙做的难看的主题终于上线了。 已经实现的: 自适应页面 lazyload图片加载 加载速度优化 目前BS的浏览器支持情况如下表 ...

June 19, 2015 · 1 min · Me

PHP实现常见排序

(图片来自互联网) 最近老高复习了下数据结构,此文会慢慢更新! <?php $count = 1000; for($i=0;$i<$count;$i++){ $random_array[$i] = rand(0,$count); } # 空白对照 $start = microtime(1); echo 'Do nothing takes:' . number_format((microtime(1) - $start), 6); echo "\n"; # 原生方法排序 $test_array = $random_array; $start = microtime(1); sort($test_array); echo 'Origin sort takes:' . number_format((microtime(1) - $start), 6); echo "\n"; # 冒泡排序 # 两两交换,思路很简单 $test_array = $random_array; $start = microtime(1); # 需要把计算个数的时间也考虑到 $count = count($test_array); # 循环n-1次 for($i=1;$i<$count;$i++){ # 循环n-1-$i次 for($j=0;$j<$count-$i;$j++){ if($test_array[$j] > $test_array[$j+1]){ $tmp = $test_array[$j]; $test_array[$j] = $test_array[$j+1]; $test_array[$j+1] = $tmp; } } } echo 'Bubble sort takes:' . number_format((microtime(1) - $start), 6); echo "\n"; # 选择排序 # 依次选择最小(大)的元素,等选择完毕自动有序 $test_array = $random_array; $start = microtime(1); $count = count($test_array); for($i=0;$i<$count-1;$i++){ # $test_array[$i]为当前最小 for($j=$i+1;$j<$count;$j++){ # 从下一个开始比较 if($test_array[$i] > $test_array[$j]){ $tmp = $test_array[$j]; $test_array[$j] = $test_array[$i]; $test_array[$i] = $tmp; } } } echo 'Select sort takes:' . number_format((microtime(1) - $start), 6); echo "\n"; # 插入排序 # 就像别人给你发扑克牌,拿到一张牌就插到你手上,并使之有序 $test_array = $random_array; $start = microtime(1); $count = count($test_array); # 直接跳过$i=0 for($i=1;$i<$count;$i++){ # 取$i左边的元素先比,比到最左 for($j=$i-1;$j>=0;$j--){ # 共$j+1个元素,其中前$j个有序 if($test_array[$j] > $test_array[$j+1]){ $tmp = $test_array[$j]; $test_array[$j] = $test_array[$j+1]; $test_array[$j+1] = $tmp; }else{ break; } } } echo 'Insertion sort takes:' . number_format((microtime(1) - $start), 6); echo "\n"; # 快速排序 # 有点递归的思想,随机一个基准,将集合分为两半,然后继续分解,直到元素个数为1或0个 $test_array = $random_array; $start = microtime(1); function quick_sort($arr){ $len = count($arr); # 符合条件<=1即无需分组 if($len <= 1) return $arr; # floor也行,主要是取整 $index = ceil($len/2); $base = $arr[$index]; $left = array(); $right = array(); for($i=0;$i<$len;$i++){ if($i == $index) continue; if($arr[$i] < $base){ $left[] = $arr[$i]; }else{ $right[] = $arr[$i]; } } $l = quick_sort($left); $r = quick_sort($right); return array_merge($l, (array)$base, $r); } quick_sort($test_array); echo 'Quick sort takes:' . number_format((microtime(1) - $start), 6); echo "\n"; ...

June 9, 2015 · 2 min · Me

centos下安装使用composer

composer的中文意思为作曲家,是php最新的包管理器。 ...

June 9, 2015 · 3 min · Me