1 import urllib22 url = u"http://www.baidu.com/wd=测试"3 urllib2.urlopen(url.encode('utf-8')).read()对url进行encode编码
分类:
Web程序 时间:
2015-04-26 15:04:13
阅读次数:
149
为了练手,使用爬虫爬一个“你懂得”图床的,使用的是urlretrieve函数,不但速度慢,还总是会报错,不是open的timeout就是上面提到的socket error。在网上找了许多办法诸如在urllib2.Request.urlopen().read()后需要调用close()关闭等方法并未奏效。
由于不想麻烦scrapy等库,所以发现了个简单粗暴的办法:
直接使用urllib自带的ope...
分类:
编程语言 时间:
2015-04-26 13:54:36
阅读次数:
295
对无锁队列的最初兴趣来自梁斌同志的一个英雄帖:http://coderpk.com/。第一次看到这个题目的时候还不知道CAS,FAA等所谓的“原子操作”,但直觉上感觉,通过对读写操作的性能优化来达到大幅提高队列性能的方法是行不通的,就算读写操作全用汇编来写,也不会和正常的read及write有数量级...
分类:
编程语言 时间:
2015-04-26 10:42:57
阅读次数:
398
#include
#include
#include
#define BUFFSIZE 4096
int main(void)
{
int n,m;
char buf[BUFFSIZE] = {0};
while((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0){
if(m = write(STDOUT_FILENO, buf, BU...
分类:
其他好文 时间:
2015-04-26 09:19:21
阅读次数:
97
libiconv
An INI file parser that can read, edit and create large INI files. Usable under Microsoft Windows, DOS, Linux, etc. Supported languages are C, C++, Visual Basic, Java, TCL, Perl, Python, e...
分类:
其他好文 时间:
2015-04-26 08:05:47
阅读次数:
184
1 FileInputStream in = null; 2 3 try { 4 in = new FileInputStream("myfile.txt"); 5 int b; 6 b = in.read(...
分类:
编程语言 时间:
2015-04-26 01:17:51
阅读次数:
183
当client,调用read(socketfd,buffer,n)时,返回0的情况:1、server端调用了close(soketfd)函数2、server调用了close(fd,SHUT_WR),关闭server端的写连接,半关闭关于close 和shutdown的过程一.void close(f...
分类:
其他好文 时间:
2015-04-25 18:06:49
阅读次数:
248
编辑一个脚本,实现批量验证文件的md5
#!/bin/bash
md5sum="/usr/bin/md5sum"
count=0 #记录有多少个文件参与md5比较
check=0 #记录有多少个文件md5是正确的
while read line
do
echo -e $line | $md5sum -c
if [ $? -eq 0 ];then
...
分类:
其他好文 时间:
2015-04-24 16:22:13
阅读次数:
336
#!/bin/bash
#systemOSautoinstall
#Mr.luo
#exit2:notmountsystemiso
pxe_dir=/mnt/p_w_picpaths/pxeboot
http_dir=/var/www/html
dhcp_dir=/etc/dhcp
echo"youhasconfigdhcpd.conf."
read-p"areyousuretorewriteit,enteryorn:"option
option=`echo$option|trA-Za-z`
whil..
分类:
Web程序 时间:
2015-04-24 10:48:07
阅读次数:
196
#!/bin/bash
#systemOSautoinstall
#Mr.luo
#exit2:notmountsystemiso
pxe_dir=/mnt/p_w_picpaths/pxeboot
http_dir=/var/www/html
dhcp_dir=/etc/dhcp
echo"youhasconfigdhcpd.conf."
read-p"areyousuretorewriteit,enteryorn:"option
option=`echo$option|trA-Za-z`
whil..
分类:
Web程序 时间:
2015-04-24 10:47:07
阅读次数:
193