一.ruby版本,需要使用curb gem
# encoding: UTF-8require 'curb'#99宿舍网页是GBK的CET_NUM = "xxxxxxxxxxxx"CET_NAME = "xxxx".encode('gb2312', 'utf-8')user = { :name => CET_NAME, :id => CET_NUM}get_score_url = "http://cet.99sushe.com/find"curl = Curl.post(get_score_url, user) do |h| h.headers["Referer"] = "http://cet.99sushe.com/"endcet = curl.body.encode("utf-8", "gb2312")puts cet.split(",")
二.curl版本,需要配合ruby转码
# encoding: UTF-8require 'open-uri'CET_NUM = "xxxxxxxxxxxx"CET_NAME = "xxxx".encode('gb2312', 'utf-8')cet_name = URI::encode CET_NAMEget_score_url = "http://cet.99sushe.com/find"result = `curl 'http://cet.99sushe.com/find' -H 'Referer: http://cet.99sushe.com/' --data 'id=#{CET_NUM}&name=#{cet_name}'`result = result.encode('utf-8', 'gb2312')cet_result = result.split(",")
?