SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    Texas
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Crawling site with javascript

    I am looking to develop a piece of software that mimics user behavior by clicking links and submitting forms on a website. To clarify, this is not being used to gather emails/spam.

    I know I can append javascript to the end of html

    ie document.form[0].submit()

    But this creates 2 problems.

    #1 How would javascript click a plain text link?

    #2 To add javascript code to the end of external HTML, I would have to grab the code from another URL and re-output it on my domain with the javascript appended. The javascript would, say, submit a form. Many sites do not allow a form to be submitted unless the referrer is from their own domain, so this would not work.

    Any ideas would be much appreciated!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,498
    Mentioned
    164 Post(s)
    Tagged
    1 Thread(s)

    clicking link

    I don't know about the referrer problem, but page elements are in arrays.
    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    function click_alert()
    {
    	alert("the link was clicked");
    }
    function click_link()
    {
    	var a_link = document.getElementsByTagName('a');
    	a_link[0].click();
    }
    </script>
    </head>
    <body>
    <p><a href="#" onclick="click_alert();">test link</a></p>
    <p><input type="button" onclick="click_link();" value="Click Link" /></p>
    </body>
    </html>


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
  •