Using curl() when Javascript is involved
Posted: Tue May 11, 2010 11:10 am
Can I use curl() to grab the contents of another page if there is a javascript pager running on the page?
I'm working with a client who has permission to use some of the contents of another website (he's a car salesman and the other site is his dealership's car listings). I've used curl() to grab the listings and preg_replace() to make some textual changes like altering the contact information to show his details. However, the other website uses a Javascript pager for its listings and when I output the altered code, this pager no longer works. The pager links don't load anything--the page just remains the same when they're clicked on.
Here is how the site I'm 'curling' is set up:
It has this form element to start:
<form name="ctl00" method="post" action="http://originalsite" id="ctl00">
Then, a button that loads the next page is this:
<input type="submit" name="btnNextUpper" value="Next >" id="btnNextUpper" />
And, the links for the pager looks like this:
<a href="javascript:__doPostBack('dgInventory$ctl01$ctl01','')">2</a>
The Javascript is this:
I am not very familiar with Java and don't know whether this script can be made to work on my page where all the code has been 'curled.' Any ideas?
I'm working with a client who has permission to use some of the contents of another website (he's a car salesman and the other site is his dealership's car listings). I've used curl() to grab the listings and preg_replace() to make some textual changes like altering the contact information to show his details. However, the other website uses a Javascript pager for its listings and when I output the altered code, this pager no longer works. The pager links don't load anything--the page just remains the same when they're clicked on.
Here is how the site I'm 'curling' is set up:
It has this form element to start:
<form name="ctl00" method="post" action="http://originalsite" id="ctl00">
Then, a button that loads the next page is this:
<input type="submit" name="btnNextUpper" value="Next >" id="btnNextUpper" />
And, the links for the pager looks like this:
<a href="javascript:__doPostBack('dgInventory$ctl01$ctl01','')">2</a>
The Javascript is this:
Code: Select all
</div><script type="text/javascript">
\/\/<![CDATA[
var theForm = document.forms['ctl00'];
if (!theForm) {
theForm = document.ctl00;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
\/\/]]>
</script>