scala 爬虫 去除不能存储的特殊字符
/**
* 去除不能存储的特殊字符
*/
def zifuChange(str: String): String = {
var bo = true
var encode = URLEncoder.encode(str)
while (bo) {
var t1 = encode.indexOf("%F0")
var zifu = ""
if (t1 > (-1)) {
try {
zifu = encode.substring(t1, t1 + 12)
} catch {
case f: StringIndexOutOfBoundsException => {
zifu = encode.substring(t1, t1 + 3)
}
}
encode = encode.replace(zifu, "")
} else {
bo = false
}
}
URLDecoder.decode(encode)
}