Open the source of an html across the net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kelly

    Open the source of an html across the net

    I got my other question wrong. I wrote a script that opens a file and
    filters out email addresses and urls etc.
    is there a way to enter a url so that my script will open
    the source of the webpage and NOT the web page itself?


  • Pedro Graca

    #2
    Re: Open the source of an html across the net

    Kelly wrote:[color=blue]
    > I got my other question wrong. I wrote a script that opens a file and
    > filters out email addresses and urls etc.
    > is there a way to enter a url so that my script will open
    > the source of the webpage and NOT the web page itself?[/color]

    All these command-line scripts

    $ php -r 'echo file_get_conten ts("http://www.example.com/"), "\n";'

    $ php -r 'echo implode("", file("http://www.example.com/")), "\n";'

    $ php -r '$f = fopen("http://www.example.com/", "r");
    $t = fread($f, 8000);
    fclose($f);
    echo $t, "\n";'


    return the same result:

    <HTML>
    <HEAD>
    <TITLE>Exampl e Web Page</TITLE>
    </HEAD>
    <body>
    <p>You have reached this web page by typing &quot;example.c om&quot;,
    &quot;example.n et&quot;,
    or &quot;example.o rg&quot; into your web browser.</p>
    <p>These domain names are reserved for use in documentation and are
    not available
    for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RF C
    2606</a>, Section 3.</p>
    </BODY>
    </HTML>


    I have

    allow_url_fopen = On

    in my php.ini
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • John Dunlop

      #3
      Re: Open the source of an html across the net

      Kelly wrote:
      [color=blue]
      > I got my other question wrong. I wrote a script that opens a file and
      > filters out email addresses and urls etc.
      > is there a way to enter a url so that my script will open
      > the source of the webpage and NOT the web page itself?[/color]

      Can you rephrase that?

      --
      Jock

      Comment

      • Chung Leong

        #4
        Re: Open the source of an html across the net

        header("Content-type: text/plain");

        if displaying the source is what you're after....

        Uzytkownik "Kelly" <foo@foo.com> napisal w wiadomosci
        news:HSL1c.6656 61$JQ1.372555@p d7tw1no...[color=blue]
        > I got my other question wrong. I wrote a script that opens a file and
        > filters out email addresses and urls etc.
        > is there a way to enter a url so that my script will open
        > the source of the webpage and NOT the web page itself?
        >
        >[/color]


        Comment

        • Christopher Glaeser

          #5
          Re: Open the source of an html across the net

          > $ php -r 'echo file_get_conten ts("http://www.example.com/"), "\n";'

          I installed php 4.3.4 and it doesn't appear to support the -r option. Was
          this added to a later release?

          php -h
          Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
          php <file> [args...]
          -a Run interactively
          -C Do not chdir to the script's directory
          -c <path>|<file> Look for php.ini file in this directory
          -n No php.ini file will be used
          -d foo[=bar] Define INI entry foo with value 'bar'
          -e Generate extended information for debugger/profiler
          -f <file> Parse <file>. Implies `-q'
          -h This help
          -i PHP information
          -l Syntax check only (lint)
          -m Show compiled in modules
          -q Quiet-mode. Suppress HTTP Header output.
          -s Display colour syntax highlighted source.
          -v Version number
          -w Display source with stripped comments and whitespace.
          -z <file> Load Zend extension <file>.


          Comment

          • Kelly

            #6
            Re: Open the source of an html across the net

            None of those work for me I get this error

            Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
            c:\apache\htdoc s\php\spamfilte r.php on line 24



            "Pedro Graca" <hexkid@hotpop. com> wrote in message
            news:c2838q$1q6 vga$2@ID-203069.news.uni-berlin.de...[color=blue]
            > Kelly wrote:[color=green]
            > > I got my other question wrong. I wrote a script that opens a file and
            > > filters out email addresses and urls etc.
            > > is there a way to enter a url so that my script will open
            > > the source of the webpage and NOT the web page itself?[/color]
            >
            > All these command-line scripts
            >
            > $ php -r 'echo file_get_conten ts("http://www.example.com/"), "\n";'
            >
            > $ php -r 'echo implode("", file("http://www.example.com/")), "\n";'
            >
            > $ php -r '$f = fopen("http://www.example.com/", "r");
            > $t = fread($f, 8000);
            > fclose($f);
            > echo $t, "\n";'
            >
            >
            > return the same result:
            >
            > <HTML>
            > <HEAD>
            > <TITLE>Exampl e Web Page</TITLE>
            > </HEAD>
            > <body>
            > <p>You have reached this web page by typing &quot;example.c om&quot;,
            > &quot;example.n et&quot;,
            > or &quot;example.o rg&quot; into your web browser.</p>
            > <p>These domain names are reserved for use in documentation and are
            > not available
            > for registration. See <a[/color]
            href="http://www.rfc-editor.org/rfc/rfc2606.txt">RF C[color=blue]
            > 2606</a>, Section 3.</p>
            > </BODY>
            > </HTML>
            >
            >
            > I have
            >
            > allow_url_fopen = On
            >
            > in my php.ini
            > --
            > --= my mail box only accepts =--
            > --= Content-Type: text/plain =--
            > --= Size below 10001 bytes =--[/color]


            Comment

            • Pedro Graca

              #7
              Re: Open the source of an html across the net

              Christopher Glaeser wrote:[color=blue][color=green]
              >> $ php -r 'echo file_get_conten ts("http://www.example.com/"), "\n";'[/color]
              >
              > I installed php 4.3.4 and it doesn't appear to support the -r option. Was
              > this added to a later release?[/color]

              You have to install the command-line version.

              php -v
              PHP 4.3.3 (cli) (built: Jan 25 2004 23:17:16)
              Copyright (c) 1997-2003 The PHP Group
              Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies


              Or simply make a php file with those commands enclosed in "<?php" and
              "?>" and open it in your browser.
              --
              --= my mail box only accepts =--
              --= Content-Type: text/plain =--
              --= Size below 10001 bytes =--

              Comment

              • Pedro Graca

                #8
                Re: Open the source of an html across the net

                [please do not top post]
                Kelly top-posted (corrected):[color=blue]
                > "Pedro Graca" <hexkid@hotpop. com> wrote in message
                > news:c2838q$1q6 vga$2@ID-203069.news.uni-berlin.de...[color=green]
                >> Kelly wrote:[color=darkred]
                >> > I got my other question wrong. I wrote a script that opens a file and
                >> > filters out email addresses and urls etc.
                >> > is there a way to enter a url so that my script will open
                >> > the source of the webpage and NOT the web page itself?[/color]
                >>
                >> All these command-line scripts
                >>
                >> $ php -r 'echo file_get_conten ts("http://www.example.com/"), "\n";'[/color][/color]
                (snip)[color=blue][color=green]
                >> return the same result:[/color][/color]
                (HTML snip)
                [color=blue]
                > None of those work for me I get this error
                >
                > Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
                > c:\apache\htdoc s\php\spamfilte r.php on line 24[/color]

                What's this spamfilter.php? and the line 24? :)

                Try making those command-line scripts into scripts usable by the web
                server:

                Save this to a .php file and open it in your browser
                <?php
                $data = file_get_conten ts('http://www.example.com/');
                echo nl2br(htmlentit ies($data));
                ?>
                --
                --= my mail box only accepts =--
                --= Content-Type: text/plain =--
                --= Size below 10001 bytes =--

                Comment

                Working...