doutou7740 2019-05-21 13:49
浏览 31
已采纳

too long

I have a list of dates that are being pulled from another website. Is it possible that when the user clicks one of the dates it redirects to the specified address? Currently, it is redirecting to my website with the page address of the website I'm pulling data from like so. http://127.0.0.1:8080/tax-professionals/prepare-and-lodge/due-dates/july-2018/ instead I need it to redirect to there website with that address.

<?php
    $page = file_get_contents("https://www.ato.gov.au/tax-professionals/prepare-and-lodge/due-dates/");

    $split = explode("</span><h1>", explode("</span></Div>", $page)[0])[1];
    echo $split
?>
  • 写回答

1条回答 默认 最新

  • douzhongjian0752 2019-05-21 14:07
    关注

    When inspecting your element, you can see that the links in $split are defined as follows:

    <a href="/tax-professionals/prepare-and-lodge/due-dates/july-2018/">July 2018</a>
    

    This means that php will automatically add your BASE_URI when clicking on that link.

    and this will result in something like:

    localhost:8080/tax-professionals/prepare-and-lodge/due-dates/july-2018/

    What you could do is add THEIR bas URI to the links:

    <?php
    
    $page = file_get_contents("https://www.ato.gov.au/tax-professionals/prepare-and-lodge/due-dates/");
    
    $split = explode("</span><h1>", explode("</span></Div>", $page)[0])[1];
    
    $split = str_replace("/tax-professionals/", "https://www.ato.gov.au/tax-professionals/", $split);
    echo $split;
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染