Home >Backend Development >PHP Tutorial >Discussion: Several methods of crawling pages with php
2. file_get_contents() function Using file_get_contents and fopen must enable allow_url_fopen. Method: Edit php.ini and set allow_url_fopen = On. When allow_url_fopen is turned off, neither fopen nor file_get_contents can open remote files.
3. fopen()->fread()->fclose() mode
4. curl method Using curl requires space to enable curl. Method: Modify php.ini under Windows, remove the semicolon in front of extension=php_curl.dll, and copy ssleay32.dll and libeay32.dll to C:WINDOWSsystem32; install the curl extension under Linux.
5. fsockopen() function socket mode Whether the socket mode can be executed correctly is also related to the server settings. Specifically, you can use phpinfo to check which communication protocols are enabled on the server. For example, my local php socket does not enable http, so I can only use udp to test it.
|