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条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改