cURL crawls the page to crawl the web page information and replace it
Replace page information
<?php $curlobj = curl_init(); // 初始化 curl_setopt($curlobj, CURLOPT_URL, "http://www.baidu.com"); // 設(shè)置訪問網(wǎng)頁的URL curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, true); // 執(zhí)行之后不直接打印出來 $output=curl_exec($curlobj); // 執(zhí)行 curl_close($curlobj); // 關(guān)閉cURL echo str_replace("百度","php",$output); ?>
We will change Baidu to PHP in the crawled Baidu page. The previous chapter was viewed under DOS. In this section, we directly use PHP to parse and view it.
Open on the web page, the effect is as follows
In this way, we have completed the replacement of the obtained page content.