Crawl source code-PHP crawl Web source problems

Source: Internet
Author: User
Crawl the General page no problem ·.
But recently to a site to get dizzy · Please help the gods to see what causes the failure. Thank you

Address: http://183.36.249.82/

The Library of our school.

I use the following code


  
   

However, this error can occur:

Server Error in '/' Application.

Runtime Error

The server I'm using is SAE. Also tried to use the functionality provided by the SAE fetch .

But unfortunately also error.

Error is: string (3) "" string "Internal Server Error"

The reasons for the multi-day study are puzzling. Solution. Thank you

Reply content:

Crawl the General page no problem ·.
But recently to a site to get dizzy · Please help the gods to see what causes the failure. Thank you

Address: http://183.36.249.82/

The Library of our school.

I use the following code


  
   

However, this error can occur:

Server Error in '/' Application.

Runtime Error

The server I'm using is SAE. Also tried to use the functionality provided by the SAE fetch .

But unfortunately also error.

Error is: string (3) "" string "Internal Server Error"

The reasons for the multi-day study are puzzling. Solution. Thank you

file_get_contentswhen using the crawl, it is common to set the HTTP context. Crawling Web pages is better with curl.


  
    array(        'method' => 'GET',        'header' => $header,        'timeout' => 10,        'protocol_version' => '1.1',    

Don't you see the Web site requires redirection? Did you just learn php? Swap with curl, file_get_contents can not catch this bar (obviously I was wrong, look at the answer of others know is OK, no culture is really scary AH).

Let me give you a reference link, I don't want to write code.
http://segmentfault.com/q/1010000000484804#a-1020000000484819
Ask the question person although ask is the question of Ruby, but people's PHP code estimate 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.