September 24, 201015 yr For reading the contents of a webpage i am using the code..... <?php $link = "http://www.xyz.com"; $file = file_get_contents($link); echo $file; ?> But the problem is that i am not able to read the ajax stuffs whichs loads after sometime.... So , i am getting just a blank table as the contents..... with all the values eual to " "(blank) Is there any way to do so using php ??? plz inform me if there is some way to do so.... as soon as possible.... pricecheck.php
September 24, 201015 yr Not exactly, you'd need to use/steal some of their javascript to make it work as well. Otherwise you could make your own table from their XHR data... <?php $link = "http://www.nseindia.com/marketinfo/equities/ajaxGetQuote.jsp?symbol=ABAN&series=EQ"; $file = file_get_contents($link); $dump = explode(';', $file); echo "<pre>"; print_r($dump); echo "</pre>"; ?>
September 24, 201015 yr Author Can we use ajax to read the contents of a webpage..... so that it could wait till the webpage loads completely.... Plz tell me if there is any way to do so ...
September 24, 201015 yr I dont know of any javascript enabled method of getting http data. I would take the table off their site and fill it using the code I posted above, it will take you some time to match up each field but you could refer back to their javascript file to see what goes where.
September 25, 201015 yr Hi atiprashant, You can read the entire current contents of a web page using this simple javascript snippet: pagecontents = document.getElementsByTagName('BODY'); This will store the page contents to variable 'pagecontents' as it stands at the time of calling the snippet, not as it stands when the page loads, so any AJAX calls will be reflected here. You can then use the various javascript string manipulation methods to extract the information you want (if needs be) and then send the resulting information as variable(s) attached to a call to an external php script using AJAX. Remember that php is processed server side before the page is sent to the browser, so anything that you need to access via php must be sent to the server, it cannot be done client side.
September 25, 201015 yr Author but the problem is that we can use AJAX only for calling the files of the same domain..... and in any other case it shows the contents before the entire page loads completely....
September 25, 201015 yr So you are trying to access the source code for a domain other than your own? If you are allowed access to this other domain then there will be much better ways of doing whatever it is you are trying to achieve. If you are not, then you probably shouldn't be doing it anyway...
September 26, 201015 yr Author but the other domain is not mines..... i am just trying to get the current stock prices from another website so that i can use it in mine... but for that i cant use AJAX... so i am asking is there any way code which allows the page to load completely and then we can read out the contents using 'explode' etc...
October 10, 201015 yr Author I dont know of any javascript enabled method of getting http data. I would take the table off their site and fill it using the code I posted above, it will take you some time to match up each field but you could refer back to their javascript file to see what goes where. That will not work for sure .... It will just echo out the contents of the page when it is called.... and not how it looks when the page loads completely...i.e when http status is 200
October 10, 201015 yr but the other domain is not mines..... i am just trying to get the current stock prices from another website so that i can use it in mine... but for that i cant use AJAX... so i am asking is there any way code which allows the page to load completely and then we can read out the contents using 'explode' etc... why not ask them if there is a way of them letting you have a feed of the information? or shouldn't you be ripping off their information and why they have supplied it in the manner that they have?
October 10, 201015 yr That will not work for sure .... It will just echo out the contents of the page when it is called.... and not how it looks when the page loads completely...i.e when http status is 200 It will work, you take the code for the table and populate it using the same XHR as their site.
Create an account or sign in to comment