下記のようなphpコードでlocalhostで実行して動作が確認できたため、
本番環境のレンタルサーバーで実行したところ、ブラウザ画面に「このページは動作していません」として
エラーが発生いたしました。
一般的にこのような現象が生じるケースがあるのでしょうか?
もしレンタルサーバー側のphp.iniの設定等の問題であれば、ここでは解決することは
出来ないと思うのですが、原因がわからず同じ経験や知識をおもちであればアドバイスを
頂きたくご質問させて頂きました。
レンタルサーバー:ロリポップ
ローカルテスト環境:MacOS/MAMP
php
1<?php 2$time_start = microtime(true); 3//get_url_loop 4require_once 'simple_html_dom.php'; 5$url=[]; 6$top_loop=["","bn=31","bn=61"]; 7 8/*start*/ 9 for ($i=0; $i <count($top_loop) ; $i++) { 10 $html = file_get_html('https://www.xxxxxxx/'.$top_loop[$i]); 11 mb_language('Japanese'); 12 $select = $html->find('.m-articleTitle_text_link'); 13 foreach($select as $elm){ 14 $url[]=$elm->href; 15 } 16 } 17 //get_contents_loop 18 19 for ($i=0; $i <count($url) ; $i++) { 20 $html=""; 21 $html = file_get_html('https://www.yyyy'.$url[$i]); 22 // mb_language('Japanese'); 23 // echo 'https://www.nikkei.com'.$url[$i]; 24 $input_data[]= $html->find('h1 span')[0]->plaintext; 25 $input_data[]= $html->find('.cmnc-publish')[0]->plaintext; 26 $input_data[]= trim(preg_replace('/[\n\r\t ]+/', "",$html->find('.cmn-announce_personnel')[0]->plaintext)); 27 28 $post_number = $html->find('.cmnc-last')[0]->plaintext; 29 $post_number = trim(preg_replace("/( | )/", "", $post_number )); 30 31 32 if($post_number>1){ 33 for ($j=2; $j <$post_number+1 ; $j++) { 34 $html2=""; 35 $html2 = file_get_html('https://www.yyyy'.$url[$i].'?h='.$j); 36 mb_language('Japanese'); 37 $input_data[] = $html2->find('h1 span')[0]->plaintext; 38 $input_data[] = $html2->find('.cmnc-publish')[0]->plaintext; 39 $input_data[]= trim(preg_replace( '/[\n\r\t ]+/', "",$html2->find('.cmn-announce_personnel')[0]->plaintext)); 40 } 41 } 42 43 } 44/*end*/ 45?> 46<!DOCTYPE html> 47<html lang="ja" dir="ltr"> 48 <head> 49 <meta charset="utf-8"> 50 <title></title> 51 <style media="screen"> 52 body{ 53 font-size: 13px; 54 } 55 table{ 56 margin:0 auto; 57 } 58 table,td{ 59 border: solid 1px #989898; 60 border-collapse:collapse; 61 } 62 .col_1{ 63 width:40px; 64 } 65 .col_2,.col_3{ 66 width:200px; 67 } 68 .col_4{ 69 width:600px; 70 } 71 </style> 72 </head> 73 74 <body> 75 <table style=""> 76 <?php for($i=0;$i<count($input_data);$i=$i+3):?> 77 <tr> 78 <td class="col_1"><?php echo 1+$i/3;?></td> 79 <td class="col_2"><?php echo $input_data[$i+1];?></td> 80 <td class="col_3"><?php echo $input_data[$i];?></td> 81 <td class="col_4"><?php echo $input_data[$i+2];?></td> 82 </tr> 83 <?php endfor;?> 84 85 </table> 86 </body> 87</html> 88 89<?php 90$time = microtime(true) - $time_start; 91echo "処理時間:".sprintf("%.20f", $time)."秒"; 92?>
ソースコードよりも先に、webサーバーが出力するerror_logを確認するのが先。
simple_html_dom.php はレンタルサーバー側にもありますか?
コメントありがとうございます、simple_html_dom.php はレンタルサーバー側に配置しております。
レンタルサーバー側のOpenSSLは有効ですか?
コメント有難うございます。今、レンタルサーバーにアクセスできない環境にいるので、後ほど速やかに確認してみます。
ローカルテスト環境は何で、レンタルサーバーはどこの何か、ってところまで掲載するのが最低限のマナー。ローカルテスト環境がWindowsなのかMacOSなのかVM上のCentOSなどなのか、XAMPPもあればMAMPもあるし、などなど、違いを第三者が分かる状態で示す必要があると思いませんか?
失礼致しました、加筆をさせて頂きました。初心者ゆえ、不足があればまたご指摘を頂ければ幸甚です。
回答2件
あなたの回答
tips
プレビュー