Can php emulate internet explorer browser requests ?

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

    #1

    Can php emulate internet explorer browser requests ?

    I'm looking to post data (GET) to a site using a php script - commands
    like fopen() file_content_ge ts won't retrieve the data. I assume this
    is because the server is expecting the request to come from a browser.

    What do I need to do to make sure the request appears to be coming
    form a browser, and what would be the best way of posting the data ?
    cURL pear fsockopen ? Do I need to recreate the headers that are sent
    via IE6 to spoof the server ? Also I think the site may use browser
    session cookies and the login page is via https.

    If it's too hard or impossible for php I guess I'll have to port my
    code over to VB .Net as I assume that program uses the IE libraries
    anyway ?
  • Colin McKinnon

    #2
    Re: Can php emulate internet explorer browser requests ?

    Captain wrote:
    [color=blue]
    > I'm looking to post data (GET) to a site using a php script - commands
    > like fopen() file_content_ge ts won't retrieve the data. I assume this
    > is because the server is expecting the request to come from a browser.
    >[/color]

    Tricky.

    You should get *something*. The PHP installation may be cobbled if it's not
    on a dedicated machine.

    The standard system can't cope with cookies, redirects and javascript.
    Snoopy (available at sourceforge) can do a lot (but IIRC not javascript)

    HTH

    C.

    Comment

    • Aidan

      #3
      Re: Can php emulate internet explorer browser requests ?

      Captain wrote:
      [color=blue]
      >I'm looking to post data (GET) to a site using a php script - commands
      >like fopen() file_content_ge ts won't retrieve the data. I assume this
      >is because the server is expecting the request to come from a browser.
      >
      >What do I need to do to make sure the request appears to be coming
      >form a browser, and what would be the best way of posting the data ?
      >cURL pear fsockopen ? Do I need to recreate the headers that are sent
      >via IE6 to spoof the server ? Also I think the site may use browser
      >session cookies and the login page is via https.
      >
      >If it's too hard or impossible for php I guess I'll have to port my
      >code over to VB .Net as I assume that program uses the IE libraries
      >anyway ?
      >
      >[/color]


      Comment

      • Hannes Dorbath

        #4
        Re: Can php emulate internet explorer browser requests ?

        <?php
        ini_set('user_a gent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
        5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

        echo file_get_conten ts('http://google.com/');

        ?>

        it's that easy.

        On 26.04.2005 14:38, Captain wrote:[color=blue]
        > I'm looking to post data (GET) to a site using a php script - commands
        > like fopen() file_content_ge ts won't retrieve the data. I assume this
        > is because the server is expecting the request to come from a browser.
        >
        > What do I need to do to make sure the request appears to be coming
        > form a browser, and what would be the best way of posting the data ?
        > cURL pear fsockopen ? Do I need to recreate the headers that are sent
        > via IE6 to spoof the server ? Also I think the site may use browser
        > session cookies and the login page is via https.
        >
        > If it's too hard or impossible for php I guess I'll have to port my
        > code over to VB .Net as I assume that program uses the IE libraries
        > anyway ?[/color]

        Comment

        • Captain

          #5
          Re: Can php emulate internet explorer browser requests ?

          If only it was that easy Hannes :)

          The is is the url of one the the pages

          http://www.betfair.com/betting/BetsM...do?=1062510579

          Compare the response from a browser requesting that page and the
          file_contents_g ets or fopen requests. I think I'll have to check out
          the pear scripts as none of the curl ones I tried seemed to work
          either

          Hannes Dorbath <light@theendof thetunnel.de> wrote in message news:<426e502e$ 0$24316$8fe63b2 a@news.disputo. net>...[color=blue]
          > <?php
          > ini_set('user_a gent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
          > 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
          >
          > echo file_get_conten ts('http://google.com/');
          >
          > ?>
          >
          > it's that easy.
          >[/color]

          Comment

          • Hannes Dorbath

            #6
            Re: Can php emulate internet explorer browser requests ?

            that page doesn't work for me even in IE. there is some timeout msg in
            the js..

            however, it's easy anyway. grab



            surf that page, take the requerst header, use

            fwrite(fsockope n('that.strange .host', 80), $headers);

            in case of https use fsockopen('ssl://that.strange.ho st', 443);

            done.

            On 27.04.2005 10:43, Captain wrote:[color=blue]
            > If only it was that easy Hannes :)
            >
            > The is is the url of one the the pages
            >
            > http://www.betfair.com/betting/BetsM...do?=1062510579
            >
            > Compare the response from a browser requesting that page and the
            > file_contents_g ets or fopen requests. I think I'll have to check out
            > the pear scripts as none of the curl ones I tried seemed to work
            > either
            >
            > Hannes Dorbath <light@theendof thetunnel.de> wrote in message news:<426e502e$ 0$24316$8fe63b2 a@news.disputo. net>...
            >[color=green]
            >><?php
            >>ini_set('user _agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
            >>5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
            >>
            >>echo file_get_conten ts('http://google.com/');
            >>
            >>?>
            >>
            >>it's that easy.
            >>[/color][/color]

            Comment

            • NC

              #7
              Re: Can php emulate internet explorer browser requests ?

              Captain wrote:[color=blue]
              >
              > I'm looking to post data (GET) to a site using a php script -
              > commands like fopen() file_content_ge ts won't retrieve the data.
              > I assume this is because the server is expecting the request
              > to come from a browser.[/color]

              Assumptions won't do. Unless you know what the problem is, you
              can't fix it. You need to look at HTTP headers that are being
              exchanged between the browser and the server. It is possible
              the server sends cookies and expects the client to have them.
              [color=blue]
              > What do I need to do to make sure the request appears to be
              > coming form a browser, and what would be the best way of
              > posting the data ? cURL pear fsockopen ?[/color]

              I have worked successfully with both fsockopen() and cURL.
              [color=blue]
              > If it's too hard or impossible for php I guess I'll have to
              > port my code over to VB .Net as I assume that program uses
              > the IE libraries anyway ?[/color]

              Since at this point you don't know what your problem is,
              switching to another programming language is premature.

              Cheers,
              NC

              Comment

              Working...