のセルへの書き込み、爆発(のfile_get_contents経由でURLのソースから特定のコンテンツのピンセットである)、そして(爆発)そのコンテンツが命の周りのマークアップ、帰国ちょうどHTMLコンテンツをフォーマットし、その後、スプレッドシートまたはCSVの単一セルに書き込みます。簡単だと思った。返しのfile_get_contentsは私が達成しようとしていますどのようなスプレッドシート
<?php
//My .html
$url = 'http://spiderlearning.com/demo/ALG_SA_U1_L1.html';
//Get content
$content = file_get_contents($url);
//Get content sections
$lesson_name = explode('<section id="nameField" class="editable" contenteditable="false">' , $content);
$section_title1 = explode('<a onclick="goToByScroll(\'obj0\')" href="#">' , $content);
$challenge_q = explode('<section id="redactor_content" class="editable" contenteditable="false">' , $content);
//Write content
$write1 = explode("</section>" , $lesson_name[1]);
$write2 = explode("</a>" , $section_title1[1]);
$write3 = explode("</section>" , $challenge_q[1]);
//Into arrays
$line1 = array($write1[0],$write2[0],$write3[0]);
$list = array($line1);
//Open .csv
$file = fopen("data/data.csv", "w");
//Write as line, delimitate with ";"
foreach ($list as $line) fputcsv($file, $line, ';');
//Close
fclose($file);
?>
:
を私が探している何がある:
CSV
これは私が持っているものです。
Unit 1 Lesson 1; 1. Challenge Questions; <p><img src="https://s3-eu-west-1.amazonaws.com/teacher-uploads.fishtree.com/SpiderLearning/1428953716a42b06b9-1ce1-4594-badd-4ab8c9b65ac0.jpeg" alt="" rel="float: left; width: 171px; height: 113.697826086957px; margin: 0px 10px 10px 0px;" style="float: left; width: 171px; height: 113.697826086957px; margin: 0px 10px 10px 0px;"></p><p>Before you begin this lesson, let's see what you already know about the topic. Take a moment to complete the three Challenge Questions that follow.</p>
フォーマットされたコンテンツでの送料の返品に問題があるようです。それはまた、同様に返されたコンテンツの周りに括弧を拾っていますが、私はどこからか分かりません。これらを逃れる方法はありますか?私は全く問題はないと一緒に、過去に同様の機能を入れているが、これは私の最初のfile_get_contents()でCSVに変換し、Iでの数週間は、最終的にそれを壁にヒットしました。 fputcsvによって導入されたもの、フィールドの区切り文字を残す方が良いでしょう foreach ($list as $line) fputcsv($file, preg_replace("/\r|\n/", "", $line), ';');
:
あなたのアプローチが理解できる:ここでは
– pregmatch
謝罪、私のマシンに保存されています。あなたが私が働いているものを見ることができるように、私はこれを主催しました。すべてのファイルはまったく同じ方法で設定され、変更や更新はありません。私はちょうどこの特定の情報がきれいな方法でスプレッドシートになっているので、私が作ったCSVからAPIを使ってCMSにコンテンツを見つけたり置き換えたりコピーしたりしてすばやく更新することができますセンス。 – SJGaliardi