(ns test.core(:require [clj-http.client :as client][http.async.client :as http]))(println (client/get "http://bj.people.com.cn/n/2014/0512/c82847-21183630.html"))
--
中文社区博客:http://blog.clojure.cn/
中文问答网站:http://ask.clojure.cn/
中文邮件列表:https://groups.google.com/d/forum/cn-clojure?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛中的“CN-Clojure”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到cn-clojure+...@googlegroups.com。
要发帖到此论坛,请发送电子邮件至cn-cl...@googlegroups.com。
通过http://groups.google.com/group/cn-clojure访问此论坛。
要查看更多选项,请访问https://groups.google.com/d/optout。
(println (client/get "http://bj.people.com.cn/n/2014/0512/c82847-21183630.html" {:as "GBK"}))就正常了clj-http提供的auto detection还是比较初级的。还是需要自己的detect字符编码,content-type头,页面meta等信息,然后做相应的转码。
在 2014年5月12日 下午5:37,胡正全 <fro...@gmail.com>写道:
求助大家用clj-http写了一个爬虫类程序,抓取UTF8的网页没问题,抓取GBK的网页是乱码。程序:(ns test.core(:require [clj-http.client :as client][http.async.client :as http]))(println (client/get "http://bj.people.com.cn/n/2014/0512/c82847-21183630.html"))我是用$lein run test.core > out 输出的文件,输出文件见附件,指定UTF8和GBK打开文件看到的都是乱码,另外用http.async.client也试了,结果相同。谁能指点一下这是怎么回事,谢谢
--
中文社区博客:http://blog.clojure.cn/
中文问答网站:http://ask.clojure.cn/
中文邮件列表:https://groups.google.com/d/forum/cn-clojure?hl=zh-CN
---
您收到此邮件是因为您订阅了Google网上论坛中的“CN-Clojure”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到cn-clojure+unsubscribe@googlegroups.com。
要发帖到此论坛,请发送电子邮件至cn-cl...@googlegroups.com。
通过http://groups.google.com/group/cn-clojure访问此论坛。
要查看更多选项,请访问https://groups.google.com/d/optout。