如何使用curl指定ip地址 [英] How can I specify ip adress using curl

查看:550
本文介绍了如何使用curl指定ip地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次执行此函数时我都需要更改ip地址我正在尝试下面的代码。但我完全糊涂了。我怎么能这样做



< b>我尝试过:



I am required to change ip adress everytime this function gets executed I am trying this code below .But I am completly confused.How can I do this

What I have tried:

function getData($domainName, $ext)
{
    $proxy = array(
        1 => array(
            '88.255.101.247',
            '8080'
        ),
        2 => array(
            '176.53.2.122',
            '8080'
        ),
        3 => array(
            '37.123.96.237',
            '8080'
        )
    );
    shuffle($proxy);
    $servers = array(
        "biz" => "whois.neulevel.biz",
        "com" => "whois.internic.net",
        "us" => "whois.nic.us",
        "info" => "whois.nic.info",
        "name" => "whois.nic.name",
        "net" => "whois.internic.net",
        "tv" => "whois.nic.tv",
        "ru" => "whois.ripn.net",
        "org" => "whois.pir.org",
        "com.tr" => "whois.nic.tr",
        "gen.tr" => "whois.nic.tr",
        "web.tr" => "whois.nic.tr",
        "k12.tr" => "whois.nic.tr",
        "org.tr" => "whois.nic.tr"
    );
    $serverName = trim($servers[$ext]);
    $fullName = $domainName . "." . $ext;
    $curl=curl_init();
    curl_setopt($curl, CURLOPT_URL, $serverName);
    curl_setopt($curl, CURLOPT_PORT, 43);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 5);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $fullName . "\r\n");
    curl_setopt($curl, CURLOPT_PROXY, $proxy[0][0]);
    curl_setopt($curl, CURLOPT_PROXYPORT, $proxy[0][1]);
    curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    $result = curl_exec($curl);
    curl_close($curl);
    print_r($result);
  }
  $veri = getData( "google", "com");
  echo htmlspecialchars($veri);

推荐答案

domainName,
domainName,


ext)
{
ext) {


proxy = array(
1 => array(
'88 .255.101.247',
'8080'
),
2 =>数组(
'176.53.2.122',
'8080'
),
3 =>数组(
'37 .123.96.237',
'8080'

);
shuffle(
proxy = array( 1 => array( '88.255.101.247', '8080' ), 2 => array( '176.53.2.122', '8080' ), 3 => array( '37.123.96.237', '8080' ) ); shuffle(


这篇关于如何使用curl指定ip地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆