Home  >  Article  >  php教程  >  采集远程网址数据

采集远程网址数据

PHP中文网
PHP中文网Original
2016-05-25 16:58:48975browse

php代码

 $http_code,
				'data' => $data
		);
	}
	   
    /**
     * 生成模拟来路地址
     * @return string
     */
    private function get_refer_uri()
    {
    	$refer[0] = 'http://www.baidu.com';
    	$refer[1] = 'https://www.google.com';
    
    	$i = time() % count($refer);
    	
    	return $refer[$i];
    }
    
    /**
     * 生成agent
     * @return string
     */
    private function get_user_agent()
    {
    	// windows + chrome
    	$str[0] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
                    (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36";
    	
    	// windows + ie
    	$str[1] = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; MASPJS; rv:11.0) like Gecko";
    
    	$i = time() % count($str);
    	
    	return $str[$i];
    }
    
    /**
     * 生成随机ip
     * @return string
     */
    private function get_rand_ip()
    {
    	$arr_1 = array("218","218","66","66","218","218","60","60","202","204",
    			"66","66","66","59","61","60","222","221","66","59","60",
    			"60","66","218","218","62","63","64","66","66","122","211");
    
    	$randarr= mt_rand(0,count($arr_1));
    	$ip1id = $arr_1[$randarr];
    
    	$ip2id=   round(rand(600000,   2550000)   /   10000);
    	$ip3id=   round(rand(600000,   2550000)   /   10000);
    	$ip4id=   round(rand(600000,   2550000)   /   10000);
    
    	return   $ip1id . "." . $ip2id . "." . $ip3id . "." . $ip4id;
    }
    
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:jpgraph 图表Next article:获取文件的相关信息