PHP can't crawl Web pages, ask a few people did not solve

Source: Internet
Author: User
Help PHP can't crawl Web page, asked a few people did not solve
This post was last edited by dz215136304 on 2013-06-11 11:35:47

The URL must be the following code in the URL, tested, when fetching, if the parameter after Q with a space, he will automatically convert "&" to "&", resulting in data can not be crawled, directly in the Web page to enter the URL is to get content, to solve the method

$url = "Http://110.75.65.8/search_turn_page_iphone.htm?sort=&q=liz claiborne&page=1&showmode=list";
echo Post ($url);

function Post ($url, $post = null)//requested Web page
{
$context = Array ();

if (Is_array ($post))
{
Ksort ($post);

$context [' http '] = array
(

' Timeout ' =>60,
' Method ' = ' POST ',
' Header ' = ' >accept-language:en/r/n ',
' Content ' = Http_build_query ($post, ', ' & '),
);
}

Return file_get_contents ($url, False, Stream_context_create ($context));
}


Error message:

Warning:file_get_contents (Http://110.75.65.8/search_turn_page_iphone.htm?sort=&q=liz claiborne&page=1 &showmode=list) [Function.file-get-contents]: Failed to open stream:http request failed! http/1.1 505 HTTP Version not supported in F:\wwwroot\getTaobao\test.php on line 25

Share to:


------Solution--------------------
Transcoding can be UrlEncode ()
  • Related Article

    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.