I have an example below from the registrar and when implemented (in a loop) it takes between 500ms to 1s between checks. I need it to run as quickly as possible, whether it be through curl or without. It seems curl takes forever between checks.
I only need the script to check one domain.
1. Is there a way to loop a post of $url and return the output foreach results, much quicker than 500ms per check? Alternative to curl? 2. Running through curl, but checking the domain availability in such a way where it does not lag in checks?
I can post the variable $domainslist (an array with a limit of 20 domains :( , or in my case, 20 copies of the same domain), it will exec curl, check availability on each and output with only 0.00022 avg lag between checks. When I loop the curl exec it will then run the above array of domain in lightning speed time, lag 5-8 seconds and execute the 20 again in lightning speed time.
3. Is there some way to stop that 5-8 second lag between the checks of each array? I assume not, only because it must reconnect curl..
Any help checking availability in minimal time, no matter which method, would be very much appreciated! Thanks!
If you had the xdebug php extension installed, which is what I use on my development machine, hence why I use var_dump a lot more than print, you would see that those headers are actually a series of lines separated by newline chars. If you view source on your output you will probably see that the output has newlines in there. ... So knowing that, you essentially want to get the first line of the…
if i were you...i would use of some programming language like python or java to use threads and do the job quicker for me...threads is by far the best means of solving this issue that i can think of...yer program running threads could return the result to yer php file... im no professional ... but this is what i'd do ...
its difficult to find an example..and lil long to write a code myself...but if you want to use python...you will have to make use of the Thread libray and the urllib for connecting to files on a server....(study up on both of them ...wont take more than a day to learn them and get started ) ... else you can wait for better answers i guess...but i dont think anything else would make it faster than threading ...
0.002s would be perfect! But I need the availability response :( is this what is slowing it down to 1s? How else can I get a response if available/unavailable without wasting too much time more than 0.002s?
The problem is, even though you only need the headers, a lot of time the web server will step in and execute the request as a GET and then return just the HEAD of the request. I'm not sure if this is still the problem, but I did work on a script that checked pages and availability across many servers and the best solution I found was batch executing about 10 curl requests in parallel using the multi curl functions. You wait until all requests complete to get a result, but essentially if you send 10 and each on average takes about 1s to return the whole request takes maybe 2s to complete all 10.
If you had the xdebug php extension installed, which is what I use on my development machine, hence why I use var_dump a lot more than print, you would see that those headers are actually a series of lines separated by newline chars. If you view source on your output you will probably see that the output has newlines in there.
So knowing that, you essentially want to get the first line of the request. This can be done with explode, or a substring etc, whatever way you prefer. But you want to parse out the first line "HTTP/1.1 200 OK" for the response code, 200 in this case. Here is a good breakdown of the common ones: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
How you choose to get the response code from that string is up to you, consider regular expressions, exploding it via the spaces, using strpos to find the first space and then taking a substr of that through the next three characters etc.
If you need more help post up what you're attempting and we'll go from there.
Ok great, thanks. I had a look at the source and noticed exactly what you said, separated by \n. I exploded $results and returned the first line.
I'm not actually looking for a response code, as it will return a 200 success code if the domain is available or not available. The API should send a return output of "available:<br>not available:<br>failed query:". Each domain checked will sit within each of those. That is what I need :)
See how I have entered 3 different URL's in the array? I would like to only check one URL for availability, but let's say for 100 times. Rather than typing out the url 100 times in the array, ie: $nodes = array('url1.com', 'url2.com', 'url3.com', 'url4.com', ..... ); is there another way I can do this so it adds a 100 count of that one url into the array on execution, dynamically?
Fatal error: Maximum execution time of 30 seconds exceeded in /home/../.../../file.php on line 27
Warning: (null)(): 2 is not a valid cURL handle resource in Unknown on line 0 Warning: (null)(): 3 is not a valid cURL handle resource in Unknown on line 0 Warning: (null)(): 4 is not a valid cURL handle resource in Unknown on line 0 Warning: (null)(): 5 is not a valid cURL handle resource in Unknown on line 0 Warning: (null)(): 6 is not a valid cURL handle resource in Unknown on line 0
Is it also able to output each time it does a check rather than loading the url 100 times and outputting all at once?