SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    extract info displayed in alert box from a webpage submission button automatically?

    there's a submit button on a web page which triggers some javascript which displays some info in an alert window. is there anyway, having automatically accessed the web page with a php script for example, to somehow trigger the submit button and get the alert window's contents programatically?

    thanks.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could in theory do this, but it could get quite complex.

    If you know the location of the alert, then you could open that directly, and use regex, otherwise, you'd have to load each linked JS resource and then search that.


  3. #3
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    With PHP, you can use cURL to scrape the page, then perhaps use simplexml to find any script tags. Then scrape the src of each, searching for anything saying alert(. I don't think it would be that much of a challenge, as long as the alert contains the text to be displayed inside the function. If it is held in a variable (i.e. the text comes from somewhere else in the JS script) then it can get very complex or impossible.

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2002
    Posts
    2,292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    yup, the text in the alert includes variables -- that's the important part. i've now found an alternative way which avoids this javascript alert thing altogether which looks pretty problematic.

    thanks for the info.


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
  •