duncanb7
asked on
Speed up grab data from remote site in php
Dear Expert,
I am using loadHTMLFile() to load remote site html page and do data extract by getelementsByName for
300 interation looping. The speed to grab the data for each time is really slow. So I try
to think whether I am using right function to do so.
There is alternative such as file_get_contents(url) and curl_setpos query. I want to know
Which is fastet method to grab 2 or 3 data from the remote site data for every iteration?
Why I have seen people sometimes using loadHTMlFile(), sometimes using curl_setpos, sometimes using
file_get_contents, what is different in term of program speed ?
If I switch back to file_get_contes($url), I need to do a loop to do a match to my data that will
cost execution time that is similar slow to getelementbtTagName by DOM, Is it Right ?
I also look curl_ method at http://www.phpfreaks.com/forums/index.php?topic=324412.0
but it doesn't tell me the advatnage of using curl_ . Could you provide this info ?
Please advise
Duncan
I am using loadHTMLFile() to load remote site html page and do data extract by getelementsByName for
300 interation looping. The speed to grab the data for each time is really slow. So I try
to think whether I am using right function to do so.
There is alternative such as file_get_contents(url) and curl_setpos query. I want to know
Which is fastet method to grab 2 or 3 data from the remote site data for every iteration?
Why I have seen people sometimes using loadHTMlFile(), sometimes using curl_setpos, sometimes using
file_get_contents, what is different in term of program speed ?
If I switch back to file_get_contes($url), I need to do a loop to do a match to my data that will
cost execution time that is similar slow to getelementbtTagName by DOM, Is it Right ?
I also look curl_ method at http://www.phpfreaks.com/forums/index.php?topic=324412.0
but it doesn't tell me the advatnage of using curl_ . Could you provide this info ?
Please advise
Duncan
<?php
$dom = new DOMDocument();
/*$dom = file_get_contents($url2);*/
@$dom->loadHTMLFile("http://www.remotesite.com/");
$data3= $dom->getElementsByTagName('table')->item(4)->getElementsByTagName('div')->item(8)->getElementsByTagName('span')->item(0)->nodeValue;
$data4= $dom->getElementsByTagName('table')->item(4)->getElementsByTagName('div')->item(12)->getElementsByTagName('span')->item(0)->nodeValue;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want faster way, I recommend you to get faster internet for the server, this is the most effective way.
ASKER
Ray_Paseur, we discuss curl here and I ask this in other thread.
So thsi thread might be going to test which method is the best,
it seems from your code in other thread, curl is more flexible
and down into detail,
Give me sometime to digest all the attach link
So thsi thread might be going to test which method is the best,
it seems from your code in other thread, curl is more flexible
and down into detail,
Give me sometime to digest all the attach link
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all of your reply
it is solved the issue by
this EE thread at
https://www.experts-exchange.com/questions/26980898/LoadHTMLFile-loading-time-in-PHP.html
it is solved the issue by
this EE thread at
https://www.experts-exchange.com/questions/26980898/LoadHTMLFile-loading-time-in-PHP.html