ProdigYu's Blog

Program

PHP随机显示图片

by ProdigYu on Aug.26, 2011, under PHP

pic.php list.txt放在网站根目录

pic.php内容如下:
<?php
$arr=file('list.txt');
$n=count($arr)-1;
header('Location: http://prodigyu.com/pic/'.$arr[rand(0,$n)]);
?>
(continue reading…)

Leave a Comment :, , more...

使用Python爬虫抓站的一些技巧总结:进阶篇

by ProdigYu on Nov.24, 2010, under Python

一、gzip/deflate支持

现在的网页普遍支持gzip压缩,这往往可以解决大量传输时间,以VeryCD的主页为例,未压缩版本247K,压缩了以后45K,为原来的1/5。这就意味着抓取速度会快5倍。 (continue reading…)

73 Comments :, more...

Python实现Ping

by ProdigYu on Oct.23, 2010, under Python

这里使用的是最简易的方式,使用python的子进程管理模块,调用系统的ping命令,代码如下: (continue reading…)

Leave a Comment :, more...

基于Python的socket编程

by ProdigYu on Oct.21, 2010, under Python

服务端:
#socket server端
#获取socket构造及常量
from socket import *
#”代表服务器为localhost (continue reading…)
Leave a Comment :, more...

配置Nginx+uwsgi更方便地部署Python应用

by ProdigYu on Oct.18, 2010, under Nginx, Python

个人觉得php最方便的就是deployment了,只要把php文件丢到支持php的路径里面,然后访问那个路径就能使用了;无论给主机添加多少php应用,只要把目录改好就没你的事了,完全不用关心php-cgi运行得如何,deployment极为方便。 (continue reading…)

Leave a Comment :, , more...

Python+Memcached网页优化

by ProdigYu on Oct.18, 2010, under Python

本来我一直不知道怎么来更好地优化网页的性能,然后最近做python和php同类网页渲染速度比较时,意外地发现一个很简单很白痴但是我一直没发现的好方法(不得不BS我自己):直接像某些php应用比如Discuz论坛那样,在生成的网页中打印出“本页面生成时间多少多少秒”,然后在不停地访问网页测试时,很直观地就能发现什么操作会导致瓶颈,怎样来解决瓶颈了。 (continue reading…)

Leave a Comment :, , more...

Spawn-fcgi启动进程马上死掉

by ProdigYu on Sep.28, 2010, under Python

如果运行Spawn-fcgi之后,ps不能发现进程,netstat不能发现端口说明Spawn-fcgi没有正常启动,可以在启动参数中加 -n 之后再启动会有详细信息.问题也就找到了.

Leave a Comment :, more...

WSGI、Flup、FastCGI、web.py的关系

by ProdigYu on Sep.27, 2010, under Python

Apache/lighttpd: 相当于一个request proxy,根据配置,把不同的请求转发给不同的server处理,例如静态的文件请求自己处理,这个时候它就像一个web server,对于fastcgi/python这样的请求转发给flup这样的Server/Gateway进行处理 (continue reading…)

Leave a Comment :, , , more...

webpy+nginx+fastcgi使用spawn-fcgi启动fastcgi

by ProdigYu on Sep.27, 2010, under Linux, Python

使用spawn-fcgi启动webpy的fastcgi方式,前端是nginx

* 服务器环境:FreeBSD 7.1
* webpy-0.32
* spawn-fcgi v1.6.0
* nginx/0.6.36
* Flup (continue reading…)

Leave a Comment :, , , , more...

Webpy + Nginx with FastCGI搭建Web.py

by ProdigYu on Sep.27, 2010, under Linux, Python

这一节讲解的是如何使用Nginx和FastCGI搭建Web.py应用 (continue reading…)

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...