Capture source code-php Web page capture source code

Source: Internet
Author: User
It's okay to crawl general pages ·. But recently I am confused about a website ·. Please help us to see what causes the failure. Thank you for choosing 183.36.249.82. The code I used is as follows {code...}, but this error will occur: ServerError... it is okay to crawl the general page ·.
But recently I am confused about a website ·. Please help us to see what causes the failure. Thank you.

Address: http: // 183.36.249.82/

Our school library.

The code I used is as follows:


  

However, this error occurs:

Server Error in '/'application.

Runtime Error

My server is SAE. I have also tried usingfetchFunction.

But it is a pity that an error is also reported.

Error: string (3) "500" string (21) "Internal Server Error"

The reason for the multiple-day study is unknown. Please answer. Thank you.

Reply content:

It's okay to crawl general pages ·.
But recently I am confused about a website ·. Please help us to see what causes the failure. Thank you.

Address: http: // 183.36.249.82/

Our school library.

The code I used is as follows:


  

However, this error occurs:

Server Error in '/'application.

Runtime Error

My server is SAE. I have also tried usingfetchFunction.

But it is a pity that an error is also reported.

Error: string (3) "500" string (21) "Internal Server Error"

The reason for the multiple-day study is unknown. Please answer. Thank you.

Usefile_get_contentsDuring crawling, you generally need to set HTTP context. It is better to capture webpages using cURL.


   array(        'method' => 'GET',        'header' => $header,        'timeout' => 10,        'protocol_version' => '1.1',    ),));$contents = file_get_contents('http://183.36.249.82/', false, $context); echo $contents; 

Didn't you find the website requires redirection? I just learned php, right? Use curl instead. file_get_contents won't be able to catch this. (obviously, I am wrong. You can see what others have answered. It is terrible to have no culture ).

Let me give you a reference connection. I don't want to write code anymore.
Http://segmentfault.com/q/1010000000484804#a-1020000000484819
Although the person who asks the question is a ruby question, the php code is probably enough for your reference.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.