如何用curl从变音域获取数据?

时间:2014-05-30 13:42:46

标签: curl host

我尝试通过curl从变音域中获取数据。好吧,它没有用,我得到错误:

Could not resolve host: http://müller.de/ Host not found

在Curl中进行以下设置

    $agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_URL, 'http://müller.de/');             
    $result = curl_exec ($ch);

1 个答案:

答案 0 :(得分:1)

在尝试了很多事情之后,答案真的很简单。我必须直接使用punycoded URL,只需在这里使用转换器:

https://iwantmyname.com/domain-tools/idns/idn-punycode-converter

我没有在stackoverflow上找到任何东西,所以我分享了我的第一个Q& A风格,啤酒花有助于某人:)