存档

2015年6月 的存档

PHP 使用curl抓取新浪微博

2015年6月28日 评论已被关闭

environment:

system:centos6.5 x86_64

php:5.6.10

funs.php和weibo.php放到同一目录

php weibo.php > res.txt

 

file1:funs.php

<?php
function loginPost($url,$data){
global $cookie_file ;
$tmp = ”;
if(is_array($data)){
foreach($data as $key =>$value){
$tmp .= $key.”=”.$value.”&”;
}
$post = trim($tmp,”&”);
}else{
$post = $data;
}
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
$return = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return $return;
}

function get($url){
global $cookie_file ;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie_file);
$return = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
return array(‘return’=>$return, ‘info’=>$info);
}

阅读全文…

分类: PHP 标签:

PHP7安装

2015年6月18日 评论已被关闭

下载地址

https://downloads.php.net/~ab/php-7.0.0alpha1.tar.bz2

http://pkg.xue135.com/php-7.0.0alpha1.tar.bz2

配置参数(不支持–with-mysql了)

./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--with-mcrypt=/usr/include \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache
分类: PHP 标签:

Linux终端显示进度条(shell实现)

2015年6月16日 1 条评论

#!/bin/sh

b=”
for ((i=0;$i<=100;i+=2))
do
printf “progress:[%-50s]%d%%\r” $b $i
sleep 0.1
b=#$b
done
echo

效果如下

processBar

 

 

分类: Linux 标签: