Top Menu

Mysql崩溃

今天打开网站发现无法连接数据库,查了下发现是Mysql下线了,又去看了下Longview,发现Memory居然用掉了1G,

接着去查了下Log,发现如下的记录

Feb 4 10:18:36 vps kernel: Out of memory: Kill process 18355 (mysqld) score 40 or sacrifice child Feb 4 10:18:36 vps kernel: Killed process 18355 (mysqld) total-vm:455884kB, anon-rss:4668kB, file-rss:0kB

Continue Reading 0

I’m here on Linode

最近实在受不了Godaddy美国机房的访问速度,当初也是贪便宜两年300优惠时候买的Deluxe Plan,正好今年4月份要到期,狠下心,准备换一个网络条件好点的机房。

Continue Reading 1

ANFtools数据库统计

自从今年4月份开始把ANFtools搜索的论坛店铺抓取的结果存入数据库之后,至今已有了4万条数据,总大小已经达到了23MB。

前段时间抽空写了段代码,对ANFtools的数据库做了个分析

论坛店铺数量:201 数据库总量:43339 2014年1月新增数量:0 2014年2月新增数量:0 2014年3月新增数量:0 2014年4月新增数量:987 2014年5月新增数量:2922 2014年6月新增数量:1847 2014年7月新增数量:3326 2014年8月新增数量:2151 2014年9月新增数量:6746 2014年10月新增数量:3939 2014年11月新增数量:5280 2014年12月新增数量:0 2014年11月1日新增数量:88 2014年11月2日新增数量:149 2014年11月3日新增数量:88 2014年11月4日新增数量:260 2014年11月5日新增数量:108 2014年11月6日新增数量:258 2014年11月7日新增数量:1409 2014年11月8日新增数量:200 2014年11月9日新增数量:380 2014年11月10日新增数量:299 2014年11月11日新增数量:0 2014年11月12日新增数量:273 2014年11月13日新增数量:3 2014年11月14日新增数量:1167 2014年11月15日新增数量:43 2014年11月16日新增数量:0 2014年11月17日新增数量:0 2014年11月18日新增数量:0 2014年11月19日新增数量:0 2014年11月20日新增数量:0 2014年11月21日新增数量:0 2014年11月22日新增数量:0 2014年11月23日新增数量:0 2014年11月24日新增数量:314 2014年11月25日新增数量:329 2014年11月26日新增数量:0 2014年11月27日新增数量:0 2014年11月28日新增数量:0 2014年11月29日新增数量:0 2014年11月30日新增数量:0

Continue Reading 0

ANFtoolsV2核心更新

这次双十一之后,发现淘宝更改了屏蔽策略,直接抓取店铺会被跳转到登陆页面。

本来是准备把抓取核心迁移到selenium,各部分都准备好了,Demo也测试成功了,但是巧合的是在调试的过程中发现从$refer = “http://login.m.taobao.com/login.htm?tpl_redirect_url=http://m.taobao.com”; 这个地址跳转到店铺不会被强制验证登陆。

那就好办了,只要对原来的抓取函数做一些修正,在原本直接抓取的基础上,模拟一次跳转。

经过测试,发现这个方案可行。不过每个小时只能抓取50家店铺,和原来一样。

不过作为一个能用就好的人,只要能凑合,就不去折腾了。下一次更新估计会把抓取核心迁移到selenium,顺便抽空把V2的店铺更新功能写掉。

PHP实现

function anftools_curlGetHtml($inputUrl){ if(!empty($inputUrl)) $url = $inputUrl; else return false; //设置cookies $cookie_jar = dirname(__FILE__)."/pic.cookie"; $refer = "http://login.m.taobao.com/login.htm?tpl_redirect_url=http://m.taobao.com"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $refer); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar); $content = curl_exec($ch); curl_close($ch); //初始化 $ch = curl_init(); //设置选项,包括URL curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, $refer); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2"); //执行并获取HTML文档内容 $output = curl_exec($ch); //释放curl句柄 curl_close($ch); if(!$output) return false; else return $output; }

Continue Reading 2

Powered by WordPress. Designed by WooThemes