Advantages and disadvantages of cURL, file_get_contents and snoopy.class.php

time:17-06-29 forum:PHP tools and code
  https://my.oschina.net/junn/blog/147936




snoopy.class.php

snoopy is a class of self - developed fsockopen, which is efficient and does not require server specific configuration support, can be used in the ordinary virtual host, but often problems. The official web site: http://sourceforge.net/projects

Snoopy is a PHP class that simulates the browser's functionality, gets the content of the web page, and sends the forms. The features of
Snoopy:
1, the content of the web page, the content of the web page, the text content of the web page (removing the HTML tag) fetchtext
3, the link to the web page, the form fetchlinks fetchform
4, the supporting agent host, the basic username / secret code verification, and the support setting. Eferer (route), cookies and header content (header file)
7, support browser redirection, and control the redirection depth of
8, can extend the link in the web to a high quality URL (default)
9, submit data and get the return value requires more than PHP4. Since it is a class of PHP without expansion support, the server does not support the best choice of curl.

file_get_contents ()

file_get_contents is a simple package of fsockopen functionality, a little less efficient, but the success rate is very high, so I usually come when Snoopy is out of question. 5.0.0 has added support for context. With context, he can send header information, customize user agent, referer and cookies. 5.1.0 adds offset and maxlen parameters to read part of the file.

curl ()

has the most powerful function and can simulate almost all aspects of browsers. Efficiency is also high, supporting multi threading, but need to open the next curl extension.

cURL is a tool that uses URL syntax to transfer files and data, and supports many protocols, such as HTTP, FTP, TELNET, etc. PHP also supports cURL libraries, which are often used for remote page grabbing and collection.

some CMS will use the curl function, which requires the CURL extension to be opened on the server. The following is the specific method:

1, the three files under the EXT directory of PHP: php_curl.dll, libeay32.dll, and replicas to the system directory.

2,
in php.ini; remove

3 before extension=php_curl.dll semicolon, restart IIS or Apache
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_exec ($ch);
curl_close ($ch);
>; *

prev:PHP cURL to achieve simulation login and... next:90% after 80% of the main body of food a...
post comment
Notice



approved   Nine cases of individual advisable h...   Ten big springs in Ji'nan   Friends who like to go to the fair o...   The origin of the streets and lanes ...   Ji'nan municipal government web site...
rand   PHP filter replacement output digita...   PHP uses $_GET to get processing cod...   Fourteen experiences in programming ...   Using JSON to implement cross domain...   PHP good verification code
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com