我已经搜索并测试了几个小时,准备放弃。 我有一个HTML页面,现在会改变每一个,然后,它的结构是这样的....
PHP代码从html页面提取数据,包括标签
100 or so lines of HTML
<div class="the start of the info I want">
500 lines of HTML that I want to extract
<div class="end of the info I want">
more lines of HTML
这是我的代码不工作,我所试过的一处。
<?php
$data = file_get_contents('http://www.soemstupidsite.xyz');
$regex = '#<div class="the start of the info I want">(.*?)<div
class="end of the info I want">#';
preg_match($regex,$data,$match);
print_r($match);
echo $match[1];
?>
返回以下错误:
PHP公告:未定义抵消:1 /home/www/mycrapcode.php第7行
到底什么是我做错了什么?
'的var_dump($比赛)'来看看它返回 –
我假设的偏移误差是因为数组为空是什么的print_r($比赛);显示。 – DeathRox
'回波$匹配[1];'这行抛*备注*,这是因为阵列'$ match'是空的。 –