私のWebクローラ抽出文に前述の "テキスト"を追加しようとしています。PHPトップ1から5の文に上記の "テキスト"を含むランダム
PHPのWebクローラー::
<?php
function get_data($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$returned_content = get_data('http://www.usmle-forums.com/usmle-step-1-forum/');
$first_step = explode('<tbody id="threadbits_forum_26"' , $returned_content);
$second_step = explode('</tbody>', $first_step[1]);
$third_step = explode('<tr>', $second_step[0]);
// print_r($third_step);
foreach ($third_step as $key=>$element) {
$child_first = explode('<td class="alt1"' , $element);
$child_second = explode('</td>' , $child_first[1]);
$child_third = explode('<a href=' , $child_second[0]);
$child_fourth = explode('</a>' , $child_third[1]);
$final = "<a href=".$child_fourth[0]."</a></br>";
?>
<li target="_blank" class="itemtitle">
<span class="item_new">text</span><?php echo $final?>
</li>
<?php
if($key==10){
break;
}
}
?>
は今、私は、Webクローラーによって抽出された最初の5つの文にランダムに追加するspanタグに記載された「テキスト」を挿入しようとして。
このように、ユーザーがページを更新するたびに、スパンタグの「テキスト」が上位5つのステートメントの間でシャッフルする必要があります。
すべてのヘルプは高く評価され..
この質問は、追加の明瞭さを必要とします。あなたは何を試みましたか?現在の出力は何ですか?意図する出力は何ですか?何が適切に機能していますか?何が失敗していますか? – mickmackusa