dongpao1926 2011-02-09 14:58
浏览 25
已采纳

curl_init和curl_exec:提取表?

hey guys, i'm completely new to cURL - i've never used it before. If i paste the following two lines inside of my sidebar ...

<?php
    $objCUrl = curl_init("http://www.domain.com/hptool/weather_v1.php?cid=43X1351&l=en");
    curl_exec($objCUrl);
?>

...i get two divs and a table inserted into my page. Is there a method where i can kind of inspect everything that gets loaded with this curl_init function? I just want to get specific stuff on my page inserted and not everything? E.g. i only want to insert the table but not the two divs that get inserted into my page.

I know i could simply hide them with css, but i'm just curious.

  • 写回答

2条回答 默认 最新

  • dongxian6715 2011-02-09 15:01
    关注

    Save the result to a string instead of outputting it.

    $url = 'http://www.domain.com/hptool/weather_v1.php?cid=43X1351&l=en';
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, false);
    
    $str = curl_exec($curl);
    

    Now you can pull whatever you need out of $str and display that.

    First place you should go is the documentation for how to use a function/library.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#ar#的问题:/* User can add his own implementation to report the HAL error return state */(语言-c语言)
  • ¥15 ImportError: DLL load failed while importing _iterative: 找不到指定的模块。
  • ¥15 如何通过交互分析得出某高危患者对放疗获益更多
  • ¥15 相关性分析中,p<0.05, r=0.29,怎么评价相关性呢
  • ¥15 docker部署Mongodb后输入命令报错?
  • ¥15 将下列流程图转变成python程序代码
  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序
  • ¥15 如何解决Excel中dependent dropdown list 的问题
  • ¥15 MddBootstrapInitialize2失败