简体   繁体   中英

Fetching data from another website

I am making a new website using PHP and I want to fetch the data from another website in which I have my profile, which contains wallpapers, logos etc.

I want to fetch the data from that website and display it on my new website in the content section.

Please give me some ideas on how to do this task in PHP.

Thanks in advance.

See eg the curl extension or the http wrapper for retrieving the content.

See the DOM extension for parsing the HTML.

您可以使用cURL向Web地址发出Web请求并获取HTML。

您可以使用cURL将请求发送到远程站点并获取结果。

Depending on the who the site is, they may have provided an API for accessing that info. That generally applies for larger sites like facebook and such.

PEAR::HTTP_Request

// Fetches yahoo.com and displays it
require_once "HTTP/Request.php";

$req =& new HTTP_Request("http://www.yahoo.com/");
if (!PEAR::isError($req->sendRequest())) {
    echo $req->getResponseBody();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM