Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 试图从网站元素中提取值_Php_Php Parser - Fatal编程技术网

Php 试图从网站元素中提取值

Php 试图从网站元素中提取值,php,php-parser,Php,Php Parser,我对PHP非常陌生,它不是我的领域,但是现在我需要从一个网站上获取一定的价值,我在互联网上查找,发现以下功能是我根据需要实现的: <?php $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://www.indiagoldrate.com/gold-rate-in-mumbai-today.htm'); curl_setop

我对PHP非常陌生,它不是我的领域,但是现在我需要从一个网站上获取一定的价值,我在互联网上查找,发现以下功能是我根据需要实现的:

          <?php
          $curl_handle=curl_init();
          curl_setopt($curl_handle,CURLOPT_URL,'http://www.indiagoldrate.com/gold-rate-in-mumbai-today.htm');
          curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
          curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
          $buffer = curl_exec($curl_handle);
          curl_close($curl_handle);
          if (empty($buffer))
          {
              print "Sorry, example.com are a bunch of poopy-heads.<p>";
          }
          else
          {
              print $buffer;
          }
          ?>

到目前为止,我能够检索整个页面,但我只对所述页面中的一个值感兴趣,我需要如何做的想法

我需要的网页代码:(简单查看源代码)


2013年7月25日,孟买
1g
2595卢比
8g
20760卢比
10g
25950卢比
100克
259500卢比
1公斤
2595000卢比
1g
2795卢比
8g
22360卢比
10g
27950卢比
100克
279500卢比
1公斤
2795000卢比

我对这部分感兴趣:

1g
Rs.2595

获取简单的\u dom\u html.php文件并将其包含在内

$html = str_get_html($buffer);
$html->find('any class etc');

通过DOM DOMDocument、XPath、simple_html_DOM、phpquery解析我需要用我检索的值更新另一个XML文件的一个元素,哪种方法最适合我的需要?这个问题缺乏任何研究。在Google或本网站上进行简单搜索会产生很多可能性。您需要html的哪一部分(您要查找的元素是否有ID或类名?
str_get_html
不是本地PHP方法…抱歉,忘了提及包含“simple dom html文件”
$html = str_get_html($buffer);
$html->find('any class etc');