Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:42:22+00:00 2026-05-16T14:42:22+00:00

How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents() ?

  • 0

How can I get the html source code of http://www.example-webpage.com/file.html without using file_get_contents()?

I need to know this because on some webhosts allow_url_fopen is disabled so you can’t use file_get_contents(). Is it possible to get the html file’s source with cURL (if cURL support is enabled)? If so, how?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:42:23+00:00Added an answer on May 16, 2026 at 2:42 pm

    Try the following:

    $ch = curl_init("http://www.example-webpage.com/file.html");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    $content = curl_exec($ch);
    curl_close($ch);
    

    I would only recommend this for small files. Big files are read as a whole and are likely to produce a memory error.


    EDIT: after some discussion in the comments we found out that the problem was that the server couldn’t resolve the host name and the page was in addition a HTTPS resource so here comes your temporary solution (until your server admin fixes the name resolving).

    what i did is just pinging graph.facebook.com to see the IP address, replace the host name with the IP address and instead specify the header manually. This however renders the SSL certificate invalid so we have to suppress peer verification.

    //$url = "https://graph.facebook.com/19165649929?fields=name";
    $url = "https://66.220.146.224/19165649929?fields=name";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: graph.facebook.com'));
    $output = curl_exec($ch);
    curl_close($ch); 
    

    Keep in mind that the IP address might change and this is an error source. you should also do some error handling using curl_error();.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can access this webpage in my firefox browser: http://www.ip-adress.com/ip_tracer/74.82.190.99 So I can get
I need to retrieve the html contents (source) of the pages, for example: www.google.com
I have downloaded the example code/demo from: http://www.technowise.in/2009/12/uploadify-aspnet-c-vb-examples-demo.html and when I try to run
i tried to change an cascading dropdownlist example http://www.codedigest.com/Articles/jQuery/224_Building_Cascading_DropDownList_in_ASPNet_Using_jQuery_and_JSON.aspx But i get always the
How can I get an html response from a url string? Using this: #lang
I can get my page's html code during my program and what I want
When using .NET's WebBrowser control, how can I get the entire HTML of the
How can I get the 85 mph from this html code with PHP +
I am trying to fetch the html source from this usl: http://books.google.com/books?id=NZlV0M5Ije4C&dq=isbn:0470284889 I used
I mean that I use below code to get html source from url. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.