コードに小さな問題があります.script タグの src 値にアクセスして、サーバー側で見つかった JavaScript ページのコンテンツを取得しました.必要なものが得られたので問題ありませんが、問題は私はhtmlコードも取得しています.htmlコードは必要ありません。以下は私がやったことです..助けてください?
<?php
//simple_html_dom.php caters for malformed html
include('simple_html_dom.php');
$html = new simple_html_dom();
//load the All code file
$html->load_file("test.txt");
$file = fopen("externalScript.txt","w");
$Script=$html->find("script");
$temp="";
$url="http://www.xyz.com";
foreach($Script AS $Spt){
$src=$Spt->src;
//check if the script src has "http://" prefix
if(strpos($src,'http://')!==0){
$src=$url."/".$src;
}
$get_script=file_get_contents($src);
$temp.=$get_script.PHP_EOL;
}
fwrite($file,($temp));
fclose($file);
?>