我使用的是Simple HTML DOM http://simplehtmldom.sourceforge.net/
?php
include_once('simple_html_dom.php');
$content = file_get_html('https://www.mesemix.hu/hu/superman-ruhanemuk/11292-szuperhosoek-mintas-zokni.html')->plaintext;
echo $content;
?>
问题是,我试图抓取的webshop中有一些包含重要值的javascript,我需要这样:
var productReference = 'SP- 418070';
有没有人知道如何获得"SP- 418070“的明文也?
发布于 2018-10-20 05:27:36
你要做的事情是:
转到他们的商店,然后按F12,然后单击"Elements tab",您可以看到其中的所有代码。您要查找的模型的选择器是:
.product_reference .editable
如果您需要查找某些内容,只需使用搜索菜单的ctrl+f。
如果您的代码结构类似于简单HTML dom上的演示版本
$html->find('.product_reference .editable', 0)->innertext;
编辑使用curl,在某个地方运行此代码,您将获得整个web内容
<?php
header('content-type:text/plain');
// define the URL to load
$url = 'example.com'; //THE URL THAT YOU NEED
// start cURL
$ch = curl_init();
// tell cURL what the URL is
curl_setopt($ch, CURLOPT_URL, $url);
// tell cURL that you want the data back from that URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// run cURL
$output = curl_exec($ch);
// end the cURL call (this also cleans up memory so it is
// important)
curl_close($ch);
// display the output
echo $output;
?>
https://stackoverflow.com/questions/52900092
复制相似问题