Using curl() when Javascript is involved

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
clavigne
Forum Newbie
Posts: 7
Joined: Tue May 11, 2010 10:53 am

Using curl() when Javascript is involved

Post by clavigne »

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:

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>
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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Using curl() when Javascript is involved

Post by Christopher »

Perhaps you should call the code that the Javascript pager is calling directly to get the data.
(#10850)
clavigne
Forum Newbie
Posts: 7
Joined: Tue May 11, 2010 10:53 am

Re: Using curl() when Javascript is involved

Post by clavigne »

I don't have access to that code. I can only see what the code outputs.
Post Reply