ruby - How to get data by curb gem better?
伊谢尔伦
伊谢尔伦 2017-04-21 11:17:17
0
1
747

I use curb gem to get some data from other website.

When I try

http = Curl.get("http://www.somesite.com/")
puts http.body_str

The data were

"{\"data\":[{\"id\":\"10000123456789\",\"name\":\"\\u1234\\u1234 \\u1234\\u1234\"},{\"id\":\"10000123465789\",\"name\":\"\\u1234\\u1234 \\u1234\\u1234\"},...}}}"

How to get data or id or name?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
迷茫

返回的是json数据吧,使用ruby的json模块处理

http://www.ruby-doc.org/stdlib-1.9.3/libdoc/json/rdoc/JSON.html#method-i-parse

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板