Ruby on rails 访问REST响应数据

Ruby on rails 访问REST响应数据,ruby-on-rails,rest,Ruby On Rails,Rest,我正在使用rest客户端gem和semrush api接收字符串响应。如何从字符串访问特定数据 答复: keyword;Position;Previous Position;Search Volume;CPC;Url;Traffic (%);Traffic Cost (%);Competition;Number of Results;Trends seo;11;0;90500;10.88;http://www.seobook.com/;6.55;11.32;0.91;839000000;0.00

我正在使用rest客户端gem和semrush api接收字符串响应。如何从字符串访问特定数据

答复:

keyword;Position;Previous Position;Search Volume;CPC;Url;Traffic (%);Traffic Cost (%);Competition;Number of Results;Trends
seo;11;0;90500;10.88;http://www.seobook.com/;6.55;11.32;0.91;839000000;0.00,0.00,0.82,0.82,0.82,0.99,0.99,0.99,0.99,0.99,0.99,0.99
seo tools;1;1;8100;8.89;http://tools.seobook.com/;5.86;8.28;0.94;71100000;0.00,0.00,0.24,0.24,0.30,0.45,0.45,0.36,0.36,0.55,0.99,0.36
seo;12;8;90500;10.88;http://tools.seobook.com/;1.81;3.13;0.91;839000000;0.00,0.00,0.82,0.82,0.82,0.99,0.99,0.99,0.99,0.99,0.99,0.99
seo training;1;1;2400;12.83;http://training.seobook.com/;1.73;3.54;0.93;27100000;0.00,0.00,0.66,0.45,0.55,0.99,0.83,0.83,0.66,0.83,0.83,0.83
seo link building;1;1;2400;12.71;http://www.seobook.com/archives/001792.shtml;1.73;3.50;0.85;30500000;0.00,0.00,0.30,0.11,0.13,0.99,0.43,0.55,0.36,0.55,0.55,0.55
seo tool;1;1;1600;7.96;http://tools.seobook.com/;1.15;1.46;0.82;28000000;0.00,0.00,0.34,0.20,0.30,0.83,0.55,0.55,0.45,0.83,0.83,0.99
seo book;1;1;1600;9.61;http://www.seobook.com/;1.15;1.76;0.30;38300000;0.00,0.00,0.30,0.25,0.34,0.55,0.66,0.83,0.55,0.66,0.99,0.55
free seo tools;1;1;1600;4.59;http://tools.seobook.com/;1.15;0.84;0.90;31500000;0.00,0.00,0.68,0.53,0.53,0.84,0.84,0.99,0.84,0.84,0.84,0.84
seobook;1;1;1000;10.36;http://www.seobook.com/;0.72;1.19;0.02;985000;0.00,0.00,0.55,0.68,0.68,0.68,0.77,0.77,0.77,0.99,0.99,0.99
seo rank checker;1;1;880;4.96;http://tools.seobook.com/firefox/rank-checker/;0.63;0.50;0.73;5470000;0.00,0.00,0.46,0.25,0.31,0.46,0.46,0.99,0.31,0.38,0.31,0.38

您可以将响应存储在一个字符串中(我简单地称之为
response
),然后逐行断开该字符串

现在,您可以用分号分隔每一行,并将这些值存储在数组中

假设我想从
seo排名检查器
行中得到
880
的值

line = response.each_line.to_a.last
array = line.split(";")
value = array[3]