Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 为什么Invoke Webrequest正确返回外来字符而cURL不正确?_Powershell_Curl_Invoke Webrequest - Fatal编程技术网

Powershell 为什么Invoke Webrequest正确返回外来字符而cURL不正确?

Powershell 为什么Invoke Webrequest正确返回外来字符而cURL不正确?,powershell,curl,invoke-webrequest,Powershell,Curl,Invoke Webrequest,通常我使用cURL来处理几乎所有的事情,但我只是注意到,当涉及到外来字符时,比如西里尔文或德语umlauts等,它并不能真正正确地返回HTML内容 比如说 Select-String -InputObject (Invoke-WebRequest -Uri "https://www.fakenamegenerator.com/gen-random-rucyr-ig.php").RawContent -Pattern '<div class="address">\s+<h3>

通常我使用cURL来处理几乎所有的事情,但我只是注意到,当涉及到外来字符时,比如西里尔文或德语umlauts等,它并不能真正正确地返回HTML内容

比如说

Select-String -InputObject (Invoke-WebRequest -Uri "https://www.fakenamegenerator.com/gen-random-rucyr-ig.php").RawContent -Pattern '<div class="address">\s+<h3>(.*?)</h3>' | %{ $_.Matches[0].Groups[1].Value }
将以西里尔文正确返回此人的姓名

但是,当使用cURL时

Select-String -InputObject (Invoke-Expression "curl.exe -s -L https://www.fakenamegenerator.com/gen-random-rucyr-ig.php") -Pattern '<div class="address">\s+<h3>(.*?)</h3>' | %{ $_.Matches[0].Groups[1].Value }
该名称将显示为ÐÐÐиÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ


那么,为什么invokewebrequest做得很好,而cURL只是返回一些胡言乱语呢?有没有办法修复cURL的结果?

在我看来,这就像是一个字符编码问题。那么,如果在没有Powershell包装器的情况下使用cURL,会发生什么呢?它返回正确的文本吗?我记得很多人都在谈论curl在Windows上不能正确处理unicode。我将尝试查找帖子。在Windows10下的Ubuntu18.04应用程序中使用Ubuntu,并使用Linux curl.exe-s-L的Windows子系统https://www.fakenamegenerator.com/gen-random-rucyr-ig.php -模式“\s+.*”| grep-after context=10检索好字符。@Trix well。。。有些不同,但仍然胡言乱语╨£╨╛╨╜╨╕╨║╨░ ╨í╨╛╨╗╨╛╨╝╨╕╨╜╨░. 正如你们大多数人已经想到的,是的,我正在使用Windows10。我自己也在VPS ubuntu 18.04上尝试了相同的curl命令,它正确返回西里尔字母。真烦人。我想我会坚持使用Invoke WebRequest。