| This article introduces three methods for php to obtain webpage content. For more information, see. The principle of using php code to obtain a webpage: capture the content and filter it by regular expressions to obtain the desired content. The programmer home has introduced a lot about the content of regular expressions. For more information, see. Php retrieves content, Method 1, file_get_contents
Php retrieves webpage content, Method 2, curl
Php: Method 3: fopen-> fread-> fclose
Note: 1. allow_url_fopen must be enabled when file_get_contents () and fopen () are used. Method: edit php. ini and set allow_url_fopen = On. when allow_url_fopen is disabled, the fopen () and file_get_contents () functions cannot open remote files. 2. when curl () is used, the curl must be enabled. Method: modify php in windows. ini, remove the semicolon before extension = php_curl.dll, and copy ssleay32.dll and libeay32.dll to C: \ WINDOWS \ system32. in Linux, install the curl extension. |