PHP How to get the specified Web page source code?

Source: Internet
Author: User
PHP How to get the specified Web page source code?
I used the file, file_get_contents, curl and other methods, found that can only open their own web site source, other sites baidu.com sina.com.cn all can not get. I don't know what's going on.

For example, with the file_get_contents, the following should be able to succeed Ah. I can't do it when I try.
$str = file_get_contents ($url);

In addition the server php.ini is opened allow_url_fopen.


Reply to discussion (solution)

What did you get out of it?

What did you get out of it?
There's nothing ...

So you
echo file_get_contents (' http://bbs.csdn.net/topics/390455646?page=1#post-394461296 ');

What can you see?

So you
echo file_get_contents (' http://bbs.csdn.net/topics/390455646?page=1#post-394461296 ');

What can you see?

Nothing at all. Take strlen length is also 0 ...

I used the awardspace on the virtual space host. Is there anything except allow_url_fopen that will restrict reading?

There may be some restrictions, use phpinfo () to see

  • 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.