Retrieving external dynamic pages with variables through PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Odin88
    Confirmed User
    • Jul 2003
    • 3267

    #1

    Retrieving external dynamic pages with variables through PHP

    I have encountered a bump on a project I am currently working on. The project requires a script to retrieve the content of an external page with variables for further processing, and I can't seem to get it to work even when using FSockOpen. This may, or should, be a failure on my part, but I looked the issue up in Google and found that others have had the same problem. Among other things, I found some interesting discussion forum threads, but the answers (if you can call it that) was rather vague and speculative and lead me no closer to a solution.

    I know for a fact that what I am seeking to do is possible, some way or the other, but this is the first time I have had to retrieve content from external pages with variables. Any input would be highly appreciated.

    Danke schön.
  • igneus
    Registered User
    • Jul 2003
    • 77

    #2
    Not sure what you mean by "with variables" .. but for just saving the contents of a webpage to a variable, have you tried "file_get_contents"? Probably the easiest solution.

    Could also use fopen and all that crap too
    icq: 201430673

    Comment

    • Nathan
      Confirmed User
      • Jul 2003
      • 3108

      #3
      odin:

      simple, do the following:

      the external page should look something like this:

      PHP Code:
      &lt;? echo "<?"; ?&gt;
      $var = "eek";
      $foo = "bar";
      $somemore = 1;
      &lt;? echo "?>"; ?&gt;
      Lets pretend that page would be http://www.fuckyoutoo.com/some.php

      you would simply do:
      include("http://www.fuckyoutoo.com/some.php"); in your main file that needs the vars.

      You can of course also not use those strange echos and print the &lt;? ?&gt; directly in the file, but you have to make sure that the server that file is on will not parse it for php since it'll of course be empty for the include() then.
      Last edited by Nathan; 08-20-2003, 11:12 PM.
      "Think about it a little more and you'll agree with me, because you're smart and I'm right."
      - Charlie Munger

      Comment

      • IMP^or^SNiTL.e
        A/S/L .. I don't names.
        • Aug 2003
        • 1177

        #4
        bah

        Comment

        • Odin88
          Confirmed User
          • Jul 2003
          • 3267

          #5
          Originally posted by Nathan
          odin:

          simple, do the following:

          the external page should look something like this:

          PHP Code:
          &lt;? echo "<?"; ?&gt;
          $var = "eek";
          $foo = "bar";
          $somemore = 1;
          &lt;? echo "?>"; ?&gt;
          Lets pretend that page would be http://www.fuckyoutoo.com/some.php

          you would simply do:
          include("http://www.fuckyoutoo.com/some.php"); in your main file that needs the vars.

          You can of course also not use those strange echos and print the &lt;? ?&gt; directly in the file, but you have to make sure that the server that file is on will not parse it for php since it'll of course be empty for the include() then.
          You do not quite understand what I am trying to do, but that is my fault I suppose. "Retrieving dynamic pages with variables" can be interpreted many ways. What I am trying to do is actually to fetch the output of dynamic pages such as http://www.google.com/search?hl=en&i...=Google+Search

          I appreciate your time and effort though.

          Comment

          • Nathan
            Confirmed User
            • Jul 2003
            • 3108

            #6
            Hey.. emm.

            whats the problem about doing that? <G>

            $lines = file("http://www.somepage.com?with=vars&foo=bar");

            that doesn't work for you?
            "Think about it a little more and you'll agree with me, because you're smart and I'm right."
            - Charlie Munger

            Comment

            • Odin88
              Confirmed User
              • Jul 2003
              • 3267

              #7
              Originally posted by Nathan
              Hey.. emm.

              whats the problem about doing that? <G>

              $lines = file("http://www.somepage.com?with=vars&foo=bar");

              that doesn't work for you?
              There's no need to be condescending. That doesn't work either.

              Comment

              • artware
                Confirmed User
                • Oct 2002
                • 268

                #8
                Is PHP set up correctly to allow the fopen wrappers? That could be the reason why it doesn't work..?

                Read about it here.

                Comment

                • rudeboi
                  Confirmed User
                  • Jun 2003
                  • 262

                  #9
                  Originally posted by Odin88


                  You do not quite understand what I am trying to do, but that is my fault I suppose. "Retrieving dynamic pages with variables" can be interpreted many ways. What I am trying to do is actually to fetch the output of dynamic pages such as http://www.google.com/search?hl=en&i...=Google+Search

                  I appreciate your time and effort though.
                  Read up on the google api, and rss.. there are php scripts out
                  there to let you use the google api as rss/rdf feeds.

                  I've got one that workds with news.google.com if you need one as an example.
                  ----------------------------------------------
                  Systems Architect
                  http://www.bitpusher.com/

                  Comment

                  • Brian911
                    Confirmed User
                    • Dec 2001
                    • 654

                    #10
                    just use wget
                    - Brian
                    [ a directive occured while processing this error ]

                    Comment

                    • fiveyes
                      Confirmed User
                      • Aug 2001
                      • 1680

                      #11
                      Get a Google Api account and then check out http://www.jappc.com/google
                      <CENTER><A HREF="http://www.hot-off-bourbon.com/" target="_blank"><IMG SRC="http://www.hot-off-bourbon.com/images/hob-logosmall.jpg" border="0"></A>

                      <FONT face="Comic Sans MS" SIZE="-1"><I>Mardi Gras, Spring Break, Wet-T, Night Club Action, UpSkirt, Oil Wrestling, Voyeur</I></FONT></CENTER>

                      Comment

                      • KC
                        Confirmed User
                        • Jan 1995
                        • 2417

                        #12
                        Yep, Google API is the way to do it..

                        http://www.google.com/apis/api_faq.html

                        Jupiter Hosting, Inc.
                        Vice President, Business Development
                        kc (AT) jupiterhosting.com

                        Comment

                        • KC
                          Confirmed User
                          • Jan 1995
                          • 2417

                          #13
                          If Google isn't the "dynamic pages" you want to pull variables from, then you'll probably need to do some sort of REG/EX to pull the correct values.

                          Jupiter Hosting, Inc.
                          Vice President, Business Development
                          kc (AT) jupiterhosting.com

                          Comment

                          • IMP^or^SNiTL.e
                            A/S/L .. I don't names.
                            • Aug 2003
                            • 1177

                            #14
                            sexy

                            Comment

                            • KC
                              Confirmed User
                              • Jan 1995
                              • 2417

                              #15
                              Originally posted by IMP^or^SNiTL.e
                              sexy
                              How much swoit are you raking in a day with that thing?

                              Jupiter Hosting, Inc.
                              Vice President, Business Development
                              kc (AT) jupiterhosting.com

                              Comment

                              • venturi
                                Confirmed User
                                • Aug 2001
                                • 386

                                #16
                                The only way you can "trap" these variables is if you parse the URI in your php script. If they are hidden or session variables you are basically screwed unless you already know the variable names associated with the page you are attempting to 'scan'.

                                People that have accomplished what I think you are trying to do have been given explicit permission from the sites they are parsing and have been granted access to some sort of an API that said site(s) have available.

                                I may not be Completely accurate here but I think that using any kind of TCP socket connection to said web page will not garner you the info you wish to gather.
                                I'm not a porn monger. I'm a porn ... STYLIST!
                                Buildit Cheap, build it Fast, Build it Right. - Pick Two.

                                Comment

                                • rudeboi
                                  Confirmed User
                                  • Jun 2003
                                  • 262

                                  #17
                                  Also, look into CURL .. you can do a lot of
                                  page scraping type work with CURL .. or just go to CPAN.org and search for page scrape and do your page scraping in perl
                                  ----------------------------------------------
                                  Systems Architect
                                  http://www.bitpusher.com/

                                  Comment

                                  Working...