www.webdeveloper.com
Results 1 to 7 of 7

Thread: Get results from "onclick" actions

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    5

    Get results from "onclick" actions

    Dear JavaScript Users and Developers,

    I am new to JavaScript, but have experience in other programming languages. I challenged myself to solve a programming problem that would be useful to me.

    There is a web page that I want to extract data from. This should be done in an automated way. Specifically, I want to save and later parse the html markup that an "onclick" link generates. This looks something like this:

    HTML Code:
    <a class="listContentLink" onclick="auctionResultListForm.auctionResultListAction.value='detail';auctionResultListForm.auctionResultListIndex.value=0;submitForm(auctionResultListForm);" href="#">
    The notable thing is that the value in
    HTML Code:
    auctionResultListForm.auctionResultListIndex.value=0;
    gets incremented by 1 for all the links I want to save/parse. So I thought I should be able to execute that "onclick" with varying "values" 0,1,2,... and post-process the resulting html.

    Am I completely wrong? Is JavaScript the right tool for this?

    I am using the Firebug extension to Firefox. If there is additional information needed, please tell me so.

    Thanks in advance and Best Regards,
    moinmoin

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    I'm honestly not sure what the question is. Or how to interpret this:

    The notable thing is that the value in
    HTML Code:
    auctionResultListForm.auctionResultListIndex.value=0;
    gets incremented by 1 for all the links I want to save/parse.
    Are you saying you want the click to increment that value? Or that this sort of link appears N times on the page, each setting {}.value to something unique?

    In either case, I'm still not sure I understand he question.

    You said you "want to save and later parse the html markup that an "onclick" link generates." But, an onclick doesn't inherently generate markup. It's possible that your onlick event triggers a form submission, page load, or AJAX request -- and if that's what you mean to capture, any JavaScript mechanism for capturing the resulting, server-generated markup will be slightly different for each of those scenarios.

    Please clarify!
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Oct 2012
    Posts
    5
    Thanks for your reply.

    Maybe I did not clearly state my goal. I am not building a website. I am trying to "scrape" an existing webpage. I wanted to save and later extract information from the hmtl page that gets displayed to me when I click the link I wrote about.

    Are you saying you want the click to increment that value? Or that this sort of link appears N times on the page, each setting {}.value to something unique?
    My description was confusing, I see now. Your second guess is right: the link appears N times on the page. I think it sets a
    Code:
    auctionResultListForm.auctionResultListIndex.value
    that is referenced after submitting the form that takes the
    Code:
    auctionResultListForm
    as argument.

    But, an onclick doesn't inherently generate markup. It's possible that your onlick event triggers a form submission, page load, or AJAX request -- and if that's what you mean to capture, any JavaScript mechanism for capturing the resulting, server-generated markup will be slightly different for each of those scenarios.
    I see. I assume from the posted "onclick" string that it is a form submission (submitForm(auctionResultListForm)). Does this mean that since I have no control over or information on the internal implementation there is no way to capture the html that gets loaded after I click?

    As I said, I am not really familiar with web programming and JavaScript, just thought there might be an easy way to do it.

    In the meantime, I am trying to use the imacros addon for firefox to automate my clicks and saves of the html pages on disk to later extract the information I want.

    Best Regards,
    moinmoin

  4. #4
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    So, you're just trying to create a solution that can pull information out of a page you have loaded in your browser? (Which would apply to both the "current" page and any page it links or submits to.)
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  5. #5
    Join Date
    Oct 2012
    Posts
    5
    exactly.

  6. #6
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Ok. If you just need a button you can click on a page-by-page basis that submits some scraped page content to a server, look into writing a bookmarklet.

    It's as simple as adding a link to your links bar with a javascript: URL. The script that follows gets injected into whatever page you're looking at. I use one at svidgen.com to make adding bookmarks easy, sans plugin.
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  7. #7
    Join Date
    Oct 2012
    Posts
    5
    Thanks for the input svidgen, I will look into it the next time.

    Meanwhile, I stomped out an imacros script that does what I want (for now).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles