gpt4 book ai didi

php - 使用 PHP 解析网页内容

转载 作者:行者123 更新时间:2023-12-02 07:03:35 25 4
gpt4 key购买 nike

我认为这是一个简单的问题,但我已经做了我所知道的,但仍然无法解决问题。我想从此链接获得输出:

http://api.microsofttranslator.com/V2/Ajax.svc/Translate?text=siapa+rektor+ipb&appId=58C40548A812ED699C35664525D8A8104D3006D2&from=id&to=en

您可以粘贴到浏览器上查看。有一些文本输出。我试过使用 PHP 中的一些函数,如 file_get_contents 和 curl。我没有使用 ajax 或 JavaScript,因为我不是这方面的专家。最后,我正在使用 XAMPP。

最佳答案

$url = 'http://api.microsofttranslator.com/V2/Ajax.svc/Translate?text=siapa+rektor+ipb&appId=58C40548A812ED699C35664525D8A8104D3006D2&from=id&to=en';

// using file_get_contents function
$content = file_get_contents($url);
echo $content;
#output# "who is the Rector of the University"

// using file function // read line by line in array
$content = file($url);
print_r($content);

#output# Array (0] => "who is the Rector of the University")

// using cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($ch);
echo $content;
#output# "who is the Rector of the University"

关于php - 使用 PHP 解析网页内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16292369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com