MT6 にて Dynamic MTML で PHP を動かそうと思っています。
やりたいことは、Goutte でのスクレイピングです。
問題点は、インデックステンプレートにおいて、
goutte.phar を require_once で読み込みたいのですが、
実行されずに、require_once 以降の PHP での処理がされない状態です。
以下、コードになります。
lang
1<!DOCTYPE html> 2<html lang="ja"> 3<head> 4 <meta charset="UTF-8"> 5 <title>sc</title> 6 <link rel="stylesheet" href="./style.css" type="text/css"> 7</head> 8<body> 9<article> 10 <h1>スクレイピング</h1> 11 <h2><mt:date></h2> 12 <?php 13 set_time_limit(180); 14 15 // Goutte 読み込み 16 require_once( 'http://www.hoge.com/scraping-hoge/goutte.phar' ); 17 18 // 見出し 19 $fp = fopen("scraping.csv","a"); 20 $column = "hoge1,hoge2,hoge3\r\n"; 21 mb_convert_variables("sjis-win", "utf-8", $column); 22 fwrite($fp, "$column"); 23 fclose($fp); 24 25 echo "end"; 26 ?> 27</article> 28</body> 29</html>
※インデックステンプレートによって吐き出された、
上記コードが書かれたPHPファイル、
goutte.phar、
Goutte-masterフォルダ は、
同じディレクトリにあります。
※require_once を除くと、最後の echo まで処理されます。
※require_once の後に use Goutte\Client; を追加すると、
画面が真っ白になり、ソースでは<body> 内は何もなくなります。
MTに関しては初心者となります。
足りない情報などがありましたら、仰ってください。
何卒、宜しくお願い申し上げます。
あなたの回答
tips
プレビュー