搜索关键字「39000038」,
http://www.mouser.cn/Search/Refine.aspx?Keyword=39000038
因为仅有一款,页面会自动跳转到
http://www.mouser.cn/ProductDetail/Molex/39-00-0038/?qs=%2fha2pyFaduicta8SJW6uUsrinUHZLSGN9RfyeL103Gs%3d搜索关键字「3900003」,有多款产品是一个列表
http://www.mouser.cn/Search/Refine.aspx?Keyword=3900003我想知道,它是直接在.net中直接判断然后跳转的,还是用js判断跳转的我要用php的file_get_content()函数抓取
http://www.mouser.cn/Search/Refine.aspx?Keyword=39000038
如何才能跟踪到
http://www.mouser.cn/ProductDetail/Molex/39-00-0038/?qs=%2fha2pyFaduicta8SJW6uUsrinUHZLSGN9RfyeL103Gs%3d

解决方案 »

  1.   

    用CURL试试,CURL中有参数可以设置
    $ch = curl_init(); 
     curl_setopt(CURLOPT_AUTOREFERER,1,$ch)
      

  2.   


    先采集一个列表页(没有的话只能抓详细页的内容来生成)生成一个列表页,采集详细页是后面的事。
    实例是这样的:http://www.rightic.com/DG/Search?partNumber=39000038&Ric5=Ric5&ROHM=ROHM&Traco=Traco&HKC=HKC&API=API我不是单单采集一个产品,而是用户自己输入「关键字」,然后页面根据这个「关键字」来采集目标网页,生成一个「列表页」所以我采集的页面是
    http://www.mouser.cn/Search/Refine.aspx?Keyword=关键字如果直接跳转到详细页,我现在没有办法得到这个详细页的地址
      

  3.   

    file_get_contents 是办不到的
    function curl_get($durl) {
      $t = parse_url($durl);
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,$durl);
      curl_setopt($ch, CURLOPT_TIMEOUT,5);
      curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
      curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      $r = curl_exec($ch);
      curl_close($ch);
      return $r;
    }echo curl_get( 'http://www.mouser.cn/Search/Refine.aspx?Keyword=39000038');
      

  4.   

    虽然已经得到这个跳转地址后的内容,但是地址本身我还是不知道如何获取$src_url = 这个跳转指向的页面地址