我正试图从外部链接获取一个数量值,但在选择特定的颜色或大小之前,我看不到这个值(该网站上的选择使用JavaScript void(0))。
有可能以某种方式触发链接并在之后获得值吗?有什么建议吗?
然而,我知道如何从url中获取静态值,请参阅以下内容:
$url = 'http://www.website.com/page.html';
$content = file_get_contents($url);
$first_step = explode( '<span id="quantity">' , $content );
$second_step = explode("</span>" , $first_step[1] );
echo $second_step[0];
也许解决方案是,您可以将流程拆分为两部分:
使用regexp 获取所有元素
preg_match_all('/<span [^>]+>/i',$content , $match);
print_r($match);
结果的搜索属性数组
$spans = array();
foreach( $match as $tag)
{
preg_match_all('/(id)=("[^"]*")/i',$tag, $spans[$tag]);
}
print_r($spans);