为什么

baidu_34554464 2016-04-07 10:44:41

$htmlstr = get_html("http://shop.m.taobao.com/shop/coupon.htm?activityId=95504434dcf441ba8988ccaf73d66917&sellerId=2301680205");
$start = strpos($htmlstr, "<span class=\"rest\">");
$end = strpos($htmlstr, "</span>", $start);
$surplusnum = substr($htmlstr,$start, $end-$start);

用curl获取页面某个class的 上面这段代码url是填的链接 $surplusnum可以获取
但是如果是下面这段代码url是字符串 $surplusnum就获取不了,$vurl打印出来是有链接的
麻烦帮忙看下这是什么原因

$htmlstr = get_html($vurl);
$start = strpos($htmlstr, "<span class=\"rest\">");
$end = strpos($htmlstr, "</span>", $start);
$surplusnum = substr($htmlstr,$start, $end-$start);
...全文
205 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2016-04-07
  • 打赏
  • 举报
回复
$s = base64_decode('aHR0cDovL3Nob3AubS50YW9iYW8uY29tL3Nob3AvY291cG9uLmh0bT9hY3Rpdml0eUlkPTYxZjY2MDE2MjI2MDRlMTlhMWU2ZjhmZDEzNmJjYzM5JmFtcDtzZWxsZXJJZD0yMjYyNzA1Mzg3');
echo file_get_contents($s);

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"><!DOCTYPE html>
<html>
    <head><script type="text/javascript">(function(){var d=new Date().getTime();var b=[];var c={};var a=function(g){try{if(window.WindVane){if(g){window.WindVane.call("WVReporter","reportError",g)}if(b.length>0){while(err=b.pop()){window.WindVane.call("WVReporter","reportError",err)}}}else{b.push(g)}}catch(f){}};var e=function(){window.onerror=function(g,f,h){a({url:window.location.href,type:"js",msg:g,file:f,line:h});return false}};if(window.navigator.userAgent.indexOf("WindVane")>0){e();window.registerWVStat=function(f,g){c["self_"+f]=g};document.addEventListener("DOMContentLoaded",function(){if(window.WindVane){c.time=new Date().getTime();c.firstByte=d;c.url=window.location.href;window.WindVane.call("WVReporter","reportDomLoad",c);a()}})}}());</script>
        <meta charset="utf-8" />
        <title>手机淘宝</title>
        <meta content="yes" name="apple-mobile-web-app-capable" />
        <meta content="black" name="apple-mobile-web-app-status-bar-style" />
        <meta name="format-detection" content="telephone=no" />
        <meta content="width=device-width,initial-scale=1,maximum-scale=1" name="viewport" />
    </head>
    <style type="text/css">
        html,body{margin:0;padding:0;}
        body{background:url(//img.alicdn.com/tps/i2/T1_rAnFBXgXXaM3kAo-320-450.jpg) top center no-repeat;}
        .f,.s,.t{text-align:center;}
        .f{padding:25px 0 11px;}
        .s,.t{padding-bottom:10px;}
        .b{color:#666;font-size:12px;width:250px;line-height:16px;margin:0 auto;padding-bottom:20px;}
        .b a{color:#ff5703;}
    </style>
<body><script type="text/javascript" src="//g.alicdn.com/alilog/wlog/0.2.10/??aplus_wap.js,spm_wap.js,spmact_wap.js" async defer></script><script type="text/javascript" src="//g.alicdn.com/sd/data_sufei/1.5.1/aplus/index.js" async defer></script>
    <div class="f">
        <img width="222" src="//img.alicdn.com/tps/i1/T15ruDFQpcXXaPEQT0-444-96.png" />
    </div>
    <div class="s">
        <img width="111" src="//img.alicdn.com/tps/i2/T1wAqFFPVbXXcKej3D-222-462.png" />
    </div>
    <div class="t">
        <img id="download" width="199" src="//img.alicdn.com/tps/i4/T1EvBgFGFeXXb9EtHW-398-80.jpg_q75.jpg" />
    </div>
    <div class="b">
        为提升更好的购物体验,即日起m.taobao.com标准版将升级为触屏版,您可以下载手机淘宝客户端或访问<a href="//m.taobao.com/?v=0">触屏版</a>,开启购物之旅。
    </div>
    <script type="text/javascript">
        (function(){
            var download = document.getElementById('download');
            var ua = navigator.userAgent;
            var url;
            if(ua.match(/Windows\sPhone/i) !=null){
                url = "http://www.windowsphone.com/zh-cn/store/app/%E6%B7%98%E5%AE%9D/0cf7aa5c-5b08-42f4-9d4e-80684c304abc";
            }
            else if(ua.match(/iPhone|iPod/i) != null){
                url = "http://itunes.apple.com/app/id387682726?mt=8";
            }
            else if(ua.match(/Android/i) != null){
              
                url = "//download.alicdn.com/wireless/taobao4android/latest/taobao4android_10000575.apk";
                
            }
            download.onclick = function(){
                if(url){
                    location.href = url;
                }
            }
        })();
    </script>
</body>
</html>
他用 js 进行了跳转,所以不是你的代码有问题,而是你的方案有问题
baidu_34554464 2016-04-07
  • 打赏
  • 举报
回复
引用 3 楼 xuzuning 的回复:
可能 假定读出到 $url 你 echo base64_encode($url); 贴出结果
输出的aHR0cDovL3Nob3AubS50YW9iYW8uY29tL3Nob3AvY291cG9uLmh0bT9hY3Rpdml0eUlkPTYxZjY2MDE2MjI2MDRlMTlhMWU2ZjhmZDEzNmJjYzM5JmFtcDtzZWxsZXJJZD0yMjYyNzA1Mzg3
xuzuning 2016-04-07
  • 打赏
  • 举报
回复
可能 假定读出到 $url 你 echo base64_encode($url); 贴出结果
baidu_34554464 2016-04-07
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
这是不可能的! 直接使用字符串和将字符串赋予变量再使用,不会有根本的变话 你需要考虑其他的因素
后者是从数据库里取出来的,会是这个原因吗
xuzuning 2016-04-07
  • 打赏
  • 举报
回复
这是不可能的! 直接使用字符串和将字符串赋予变量再使用,不会有根本的变话 你需要考虑其他的因素

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧