php选拔curl访问域名重回405 method not allowed提醒的减轻情势

状态码提醒405/Method Not Allowed意味不帮助诉求的措施,那个错误并不遍布。

php生成短域名函数

<?php 
#使用示例
echo getBaseDomain('http://blog.jp.goo.ne.jp/index.php')->domain;echo "\n";
echo getBaseDomain('http://51.ca/index.php')->domain;echo "\n";
echo getBaseDomain('http://blog.ab.cc.win.aisa.hk/index.php')->domain;echo "\n";


function getBaseDomain($url=''){
  if(!$url){
    return $url;
  }
  #列举域名中固定元素
  $state_domain = array(
    'al','dz','af','ar','ae','aw','om','az','eg','et','ie','ee','ad','ao','ai','ag','at','au','mo','bb','pg','bs','pk','py','ps','bh','pa','br','by','bm','bg','mp','bj','be','is','pr','ba','pl','bo','bz','bw','bt','bf','bi','bv','kp','gq','dk','de','tl','tp','tg','dm','do','ru','ec','er','fr','fo','pf','gf','tf','va','ph','fj','fi','cv','fk','gm','cg','cd','co','cr','gg','gd','gl','ge','cu','gp','gu','gy','kz','ht','kr','nl','an','hm','hn','ki','dj','kg','gn','gw','ca','gh','ga','kh','cz','zw','cm','qa','ky','km','ci','kw','cc','hr','ke','ck','lv','ls','la','lb','lt','lr','ly','li','re','lu','rw','ro','mg','im','mv','mt','mw','my','ml','mk','mh','mq','yt','mu','mr','us','um','as','vi','mn','ms','bd','pe','fm','mm','md','ma','mc','mz','mx','nr','np','ni','ne','ng','nu','no','nf','na','za','aq','gs','eu','pw','pn','pt','jp','se','ch','sv','ws','yu','sl','sn','cy','sc','sa','cx','st','sh','kn','lc','sm','pm','vc','lk','sk','si','sj','sz','sd','sr','sb','so','tj','tw','th','tz','to','tc','tt','tn','tv','tr','tm','tk','wf','vu','gt','ve','bn','ug','ua','uy','uz','es','eh','gr','hk','sg','nc','nz','hu','sy','jm','am','ac','ye','iq','ir','il','it','in','id','uk','vg','io','jo','vn','zm','je','td','gi','cl','cf','cn','yr','com','arpa','edu','gov','int','mil','net','org','biz','info','pro','name','museum','coop','aero','xxx','idv','me','mobi','asia','ax','bl','bq','cat','cw','gb','jobs','mf','rs','su','sx','tel','travel'
  );

  if(!preg_match("/^http/is", $url)){
    $url="http://".$url;
  }

  $res = null;
  $res->domain = null;
  $res->host = null;
  $url_parse = parse_url(strtolower($url));
  $urlarr = explode(".", $url_parse['host']);
  $count = count($urlarr);

  if($count <= 2){
    #当域名直接根形式不存在host部分直接输出
    $res->domain = $url_parse['host'];
  }elseif($count > 2){
    $last = array_pop($urlarr);
    $last_1 = array_pop($urlarr);
    $last_2 = array_pop($urlarr);

    $res->domain = $last_1.'.'.$last;
    $res->host = $last_2;

    if(in_array($last, $state_domain)){
      $res->domain=$last_1.'.'.$last;
      $res->host=implode('.', $urlarr);
    }

    if(in_array($last_1, $state_domain)){
      $res->domain = $last_2.'.'.$last_1.'.'.$last;
      $res->host = implode('.', $urlarr);
    }
    #print_r(get_defined_vars());die;
  }
  return $res;

}

<?
//获取当前的域名:
echo $_SERVER[‘SERVER_NAME’];
//获取来源网站,即点击来到本页的上页网站
echo $_SERVER[“HTTP_REFERER”];
$_SERVER[‘REQUEST_URI’];//获取当前域名的后缀
$_SERVER[‘HTTP_HOST’];//获取当前域名
dirname(__FILE__);//获取当前文件的梗概路线
dirname(__FILE__).”/../”;//获取当前文件的上顶尖物理路线
?>

致使那个荒唐是就算鉴于curl暗中认可是行使post格局实行付出国访问问的,post格局在此类域名下是平素不权力的,比如在测验www.amazon.cn的时候就涌出了那类难题,而修改为get的点子,何况扩充了header头后,就能够符合规律访谈,个人推断,大概是亚马逊(亚马逊)那边基本上都以使用get的法门,才会被感到是人为的点击,对post做了相应屏蔽。

public function createRandCode($string) {
    $code = '';
    $hex_code = '1qaz2wsx3edc4rfv5t-gb6yhn7ujm8ik9ol0p_';
    $now = microtime(true) * 10000;
    $strlen = strlen($hex_code);

    $hash_code = hash('sha256', $string);

    // 这里会为编码定义一个随机的长度,长度取决于step
    $step = rand(8, 16);
    $count = ceil(strlen($hash_code) / $step);

    for($i = 0; $i < $count; $i++) {
      $start = $i * $step;
      $hex_num = substr($hash_code, $start, $step);
      $num = 0x3fffffff & (1 * '0x' . $hex_num);
      $n = $num % $strlen;
      $code .= $hex_code[$n];
    }

    return $code;
  }

PHP遵照UWranglerL提取根域名,个人职业中用到,由于互联网上过多代码都不可能博取准确结果就和好写了三个,应接我们利用并建议个中的bug.

复制代码 代码如下:

上述为四个基本curl访谈的方法,由于这里必要经过选用IPv6的法子,所以加了相应的选项,相信大家能看的掌握,平常断断续续利用的选项地点都有出现,我们根据必要选拔。

如上所述便是本文给大家大饱眼福的代码的全体内容了,希望大家能够喜欢。

你恐怕感兴趣的小说:

  • php选取curl访谈域名再次来到405 method not
    allowed提醒的减轻措施
  • php中拿走UPRADOL的根域名的代码
  • PHP获取当前绝对于域名目录的艺术
  • php生成短域名函数
  • PHP完毕获取域名的法子小结
  • php获取根域名艺术汇总
  • 利用PHP实现短域名互转
  • 解析PHP获取当前网址及域名的兑当代码
  • PHP获取网站的拔尖域名函数代码
  • PHP自定义函数获取UPRADOL中一流域名的办法

你只怕感兴趣的篇章:

  • 365bet体育开户,PHP完成通过UXC90L提取根域名
  • php选择curl访谈域名重回405 method not
    allowed提示的化解办法
  • php中收获U悍马H2L的根域名的代码
  • PHP获取当前相对于域名目录的点子
  • php生成短域名函数
  • PHP完毕获取域名的措施小结
  • php获取根域名艺术汇总
  • 动用PHP达成短域名互转
  • 365bet体育平台,PHP获取网站的拔尖域名函数代码
  • PHP自定义函数获取U帕杰罗L中一级域名的秘诀

发表评论

电子邮件地址不会被公开。 必填项已用*标注