---
title: "curl 下载 字符集转化"
author: "wushexin"
date: "2011-04-21T10:02:53Z"
tags: []
categories: ["操作系统"]
slug: "curl"
draft: false
lastmod: "2011-04-21T10:02:53Z"
id: 1010763
url: "https://wushexin.iteye.com/blog/1010763"
---

shell 写道

curl 下载页面时，时常会乱码，可以用：iconv -f gbk -t utf-8 来转码；示例：

\[oracle@localhost ~]$ curl http://www.ip138.com/ip2city.asp | grep body

&lt;body style="margin:0px"&gt;&lt;center&gt;?μ?Pμ?·?￡o\[114.249.221.61] &lt;/center&gt;&lt;/body&gt;&lt;/html&gt;

\[oracle@localhost ~]$ curl http://www.ip138.com/ip2city.asp | grep body | iconv -f gbk -t utf-8

&lt;body style="margin:0px"&gt;&lt;center&gt;您的IP地址是：\[114.249.221.61] &lt;/center&gt;&lt;/body&gt;&lt;/html&gt;