DeX Posted July 7, 2014 Share Posted July 7, 2014 I'm writing a PHP script to pull information from another website which I don't own. That website uses javascript for pagination, splitting data across 3 pages. They also have a function to list all their data on one page but it requires clicking the link on the page which runs a javascript AJAX call. I want to pull all that data with PHP but how do I emulate the Javascript AJAX call in my code so I can get all that data instead of just the first page? Even if I could just call that function and then parse the information it returns to me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/ Share on other sites More sharing options...
requinix Posted July 7, 2014 Share Posted July 7, 2014 Use your browser, or an extension if it's not native, to watch the HTTP request that gets sent with the AJAX. Then simulate that using PHP - probably cURL. Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484177 Share on other sites More sharing options...
Psycho Posted July 7, 2014 Share Posted July 7, 2014 Or, contact the website owner and first ask for permission to re-purpose their data. They may already have a service to return all the data in a more manageable format. Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484184 Share on other sites More sharing options...
Q695 Posted July 7, 2014 Share Posted July 7, 2014 <script src="url" Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484193 Share on other sites More sharing options...
Psycho Posted July 7, 2014 Share Posted July 7, 2014 <script src="url" Â That won't work for what the OP is wanting. He is wanting to automatically get content based on the execution of the JavaScript. But, it seems, he is just scraping the page. Can't execute JS from within PHP. Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484196 Share on other sites More sharing options...
DeX Posted July 8, 2014 Author Share Posted July 8, 2014 (edited) Yes, I'm trying to pull a list of stores from a mall directory but they have the listing split across 3 pages and you browse the pages using javascript links. I want to pull all the stores from the 3 pages. More specifically they have a Javascript link for returning all stores, I want that one. Â EDIT: This one -Â http://www.crossironmills.com/shopping/store-directory/alpha/ Edited July 8, 2014 by DeX Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484276 Share on other sites More sharing options...
Q695 Posted July 12, 2014 Share Posted July 12, 2014 So like a popup on the page? Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1484789 Share on other sites More sharing options...
DeX Posted July 21, 2014 Author Share Posted July 21, 2014 So like a popup on the page? No, they're using pagination to display 20 results at a time. You click the arrow and it displays the next 20 results. I want to somehow get all the results using a HTTP GET request on my own PHP page. Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1485829 Share on other sites More sharing options...
Psycho Posted July 21, 2014 Share Posted July 21, 2014 Have you looked into requinix's suggesting of using cURL? Quote Link to comment https://forums.phpfreaks.com/topic/289538-how-do-i-call-a-javascript-function-on-remote-website/#findComment-1485835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.