##わからないこと
お世話になります。
下のサイトを読み込んで、html構造をスクレイピングしようとしているのですが、
httpエラー(301)が発生し取得できません。
https://www.co-medical.com/ns/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n <html><head>\n <title>301 Moved Permanently</title>\n </head><body>\n <h1>Moved Permanently</h1>\n <p>The document has moved <a href="https://www.co-medical.com/ns/search/">here</a>.</p>\n </body></html>\n
ウェブに表示する場合は問題ないのですが、コマンドをたたいて読み込ませようとすると失敗します。
この原因はパラメータの不足にあるのか、ページがリダイレクトで表示されているのでしょうか
$userAgent = new userAgent(); $agent = $userAgent->agent(rand(1, 80)); $ch = curl_init(); $url = 'http://www.co-medical.com/ns/search/?search_redirect=1&jobtype=OC001&jobtype_roma=ns&mode=popup'; curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $page = curl_exec($ch); dd($page);
書いたコードは上記のみです。
ご教授いただければ幸いです。
よろしくお願いいたします。