<?php $User = "username"; $Pwd = "password"; $Url = "example.com/"; $html = file_get_contents("http://" . $User . ":" . $Pwd . "@" . $Url); preg_match("|<h3>(.*)</h3>|is",$html,$Out); file_put_contents("a.txt", $Out[1]. "\n"); /* echo $Out[1]; */
質問文通りに組みました。
このプログラムをutf-8で保存して実行してください。
<?php mb_internal_encoding("utf-8"); $id = "ユーザー名"; $pass = "パスワード"; $domain = "ドメイン名"; $filename = "a.txt"; $url = "http://" . $id . ":" . $pass . "@" . $domain; $str = file_get_contents($url); $str = mb_convert_encoding($str, "utf-8", "auto"); preg_match("/<h3>(.+)<\/h3>/ismu", $str, $arr); header("Content-Disposition: attachment; filename=" . $filename); echo $arr[1] . "\n"; ?>
▽3
●
asatoryu ●166ポイント ベストアンサー |
このプログラムをutf-8で保存して実行してください。
サーバーのphpファイルがあるフォルダに書き込み権限を与えてください。
<?php mb_internal_encoding("utf-8"); $id = "ユーザー名"; $pass = "パスワード"; $domain = "ドメイン名"; $filename = "a.txt"; $url = "http://" . $id . ":" . $pass . "@" . $domain; $str = file_get_contents($url); $str = mb_convert_encoding($str, "utf-8", "auto"); preg_match("/<h3>(.+)<\/h3>/ismu", $str, $arr); file_put_contents($filename, $arr[1]); echo '保存完了'; ?>