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:
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.
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.
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
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.
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.)
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.
Bookmarks