SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making a Shell Script Emulate a Web Browser

    Hi. Is it possible to make a shell script emulate a web browser? I can set up a CRON job that will execute a PHP script (or ASP, etc.) that, in turn, does "something", like modify database records or copy files. But, what I want to do is different. I'll try to explain this using a hypothetical example: Suppose I have a script that does three things:

    1) Randomly selects and displays an image from among several images stored on the web server.
    2) Makes a record in a database of the "hit" on the randomly selected image.
    3) Refreshes itself (using an HTTP refresh, for example), thus displaying another randomly selected image and starting the whole process over.

    It's simple to do this with a page that's viewed in a web browser. And I can set up a CRON job (or run a command line prompt) of the script and it will take care of (1) and (2) above, but I don't see how (or if) I can get it to execute (3) above. Is it possible? Thanks for any help! (Sorry for the silly and simple example).

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you try using lynx?

    http://lynx.browser.org/

    If you really want to be browsing a webpage from a shell account you need to use a web browser, of course since shell accounts are text only and lynx is text only you won't actually see any images, but the page should refresh.

    All in all this seems like an odd request, perhaps if you told us why you wanted this we could give you a better method.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi. Basically what I'm trying to do is read the contents of a page on a remote web server. The page is a frames page with two .asp pages for frame sources. One frame uses, ostensibly, either an HTTP refresh or some kind of JavaScript countdown to refresh itself every 30 seconds, and each time it does so, a different page comes up in the other frame as well, and that second page gets a "hit", which is probably stored in a database. If I were to leave my browser window open to the frames page, it would continue in this manner indefinitely, reloading every 30 seconds and counting the hits to the various pages (I don't know if they're random or what). What I'm trying to do is simulate this process without having to have a browser window open to this page all the time, so I thought perhaps there was a way to set up a script (most likely PHP) and run it via a CRON job. But, of course, there's no actual output.

    I know this sounds crazy, but hey, it's for a client!


  4. #4
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you want to increment a field in the database every 30 seconds and change the market for which picture is current?

    That is all very easily done in a php/asp/cf/perl script.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  5. #5
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, that's not it. See, I told you this was crazy. The site that I mentioned (the frames site) is a specific, existing site which I do not control. In effect, I need to make that specific site think that I visited it (well, not me specifically, but that SOMEONE visited it). Further, I need it to act as though I was on the page while it refreshed "x" number of times. So, I need this remote site (which, again, I don't control) to think that I'm sitting here with its page up on my browser for some length of time when in actuality I'm not visiting the site at all. So I was thinking I might be able to accomplish this with a CRON job that runs a PHP script. Sorry if I haven't explained this very well. I know, I know... but don't ask why, because I'm not entirely sure myself! I know what I need to do, I'm just not sold on the purpose of it, nor do I know HOW to do it. But what the boss wants...

  6. #6
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just to let you know, to me this sounds like a scam to autovote on some list.

    basically run this php script every 30 seconds:

    Code:
    <?
    $web_content = fopen("http://mysite.com", "r");
    
    fclose($web_content);
    
    ?>
    You can't sit on the page and let it use javascript to reload itself with a php script, but loading it directly every 30 seconds should do the same thing if it works as you described.

    Of course you can't access the frame page, look at the page source and access the actual page that's refreshing - php wouldn't render the frames so it wouldn't access what is inside the frames.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •