Loading ...
Sorry, an error occurred while loading the content.

Get HTML code of a web page

Expand Messages
  • thisistrinath
    Hi everyone, I want to know that how can I obtain HTML source code of a web page with the use of a built-in PHP function(s). It should work like if I provide
    Message 1 of 3 , Mar 9 4:18 PM
    • 0 Attachment
      Hi everyone,
      I want to know that how can I obtain HTML source code of a web page
      with the use of a built-in PHP function(s). It should work like if I
      provide the URL to it, it will in turn provide me its entire HTML code
      or may be just the content inside specific tag like body, head, title etc.
      Please reply.
      Thank you
    • Ankur Dave
      The easiest one is .. http://in2.php.net/manual/en/function.file-get-contents.phpso
      Message 2 of 3 , Mar 10 2:12 AM
      • 0 Attachment
        The easiest one is ..
        http://in2.php.net/manual/en/function.file-get-contents.php

        <?
        $content=file_get_contents("http://www.google.com");
        echo $content;
        ?>

        so now $content is in html format.

        -=-=-=-=-=-=-=-=-=-
        Regards :: Ankur Dave :: http://ullu.wordpress.com


        -----Original Message-----
        From: bang-phpug@yahoogroups.com [mailto:bang-phpug@yahoogroups.com] On
        Behalf Of thisistrinath
        Sent: Saturday, March 10, 2007 5:49 AM
        To: bang-phpug@yahoogroups.com
        Subject: [bang-phpug] Get HTML code of a web page

        Hi everyone,
        I want to know that how can I obtain HTML source code of a web page
        with the use of a built-in PHP function(s). It should work like if I
        provide the URL to it, it will in turn provide me its entire HTML code
        or may be just the content inside specific tag like body, head, title
        etc.
        Please reply.
        Thank you



        ------------------------ Yahoo! Groups Sponsor --------------------~-->
        Great things are happening at Yahoo! Groups. See the new email design.
        http://us.click.yahoo.com/lOt0.A/hOaOAA/yQLSAA/_____B/TM
        --------------------------------------------------------------------~->


        Yahoo! Groups Links





        The information contained in, or attached to, this e-mail, contains confidential information and is intended solely for the use of the individual or entity to whom they are addressed and is subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email.

        www.aztecsoft.com
      • thisistrinath
        Ok I understand that $content is now a string containing HTML code of the given URL. But now when I did the following, it displays nothing.
        Message 3 of 3 , Mar 10 12:41 PM
        • 0 Attachment
          Ok I understand that $content is now a string containing HTML code of
          the given URL. But now when I did the following, it displays nothing.

          <?
          $content=file_get_contents("http://www.google.com");
          $show=substr($content,0,50);
          echo $show;
          ?>

          why is it so?
          I want the $show to display its content
          Please post. Thank you






          --- In bang-phpug@yahoogroups.com, "Ankur Dave" <ankurd@...> wrote:
          >
          >
          > The easiest one is ..
          > http://in2.php.net/manual/en/function.file-get-contents.php
          >
          > <?
          > $content=file_get_contents("http://www.google.com");
          > echo $content;
          > ?>
          >
          > so now $content is in html format.
          >
          > -=-=-=-=-=-=-=-=-=-
          > Regards :: Ankur Dave :: http://ullu.wordpress.com
          >
          >
          > -----Original Message-----
          > From: bang-phpug@yahoogroups.com [mailto:bang-phpug@yahoogroups.com] On
          > Behalf Of thisistrinath
          > Sent: Saturday, March 10, 2007 5:49 AM
          > To: bang-phpug@yahoogroups.com
          > Subject: [bang-phpug] Get HTML code of a web page
          >
          > Hi everyone,
          > I want to know that how can I obtain HTML source code of a web page
          > with the use of a built-in PHP function(s). It should work like if I
          > provide the URL to it, it will in turn provide me its entire HTML code
          > or may be just the content inside specific tag like body, head, title
          > etc.
          > Please reply.
          > Thank you
          >
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
          > The information contained in, or attached to, this e-mail, contains
          confidential information and is intended solely for the use of the
          individual or entity to whom they are addressed and is subject to
          legal privilege. If you have received this e-mail in error you should
          notify the sender immediately by reply e-mail, delete the message from
          your system and notify your system manager. Please do not copy it for
          any purpose, or disclose its contents to any other person. The views
          or opinions presented in this e-mail are solely those of the author
          and do not necessarily represent those of the company. The recipient
          should check this e-mail and any attachments for the presence of
          viruses. The company accepts no liability for any damage caused,
          directly or indirectly, by any virus transmitted in this email.
          >
          > www.aztecsoft.com
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.