【发布时间】:2019-09-05 18:22:05
【问题描述】:
我有一个应用程序通过链接自动访问 URL。只要 URL 不包含 Unicode,它就可以正常工作。
例如,我有一个链接:
<a href="https://example.com/catalog/kraków/list.html">Kraków</a>
该链接在源代码中仅包含纯 ó 字符。当我尝试这样做时:
$href = $crawler->filter('a')->attr('href');
$html = file_get_contents($href);
返回 404 错误。如果我在浏览器中访问该 URL,那很好,因为浏览器将 ó 替换为 %C3%B3。
我应该怎么做才能通过file_get_contents()访问该URL?
【问题讨论】:
标签: php url domcrawler