@NARKOZ對你的問題有正確的答案,你爲什麼試圖做的不工作。你應該接受這個答案。
解決您的問題,試試這個:
require 'open-uri'
require 'json'
require 'pp'
gaga = JSON.parse(open('http://api.twitter.com/1/statuses/user_timeline.json?include_entities=1&include_available_features=1&contributor_details=true&include_rts=true&user_id=14230524').read)
pp gaga.map{ |tweet| tweet['text'] }[0..3]
#=> ["Here's my LIVE radio performance on the Howard Stern Show! http://bit.ly/pighVL\"",
#=> "Thanks baby. I'm a die hard monsterfan [email protected]: @ladygaga 's album speaks to me more than any other album ever. #diehardfan",
#=> "http://twitpic.com/5s4f2h - Just left @HowardStern, rockers with long hair have a sweetspot for girls like me. He was a doll. :)",
#=> "SURPRISE MONSTERS! You can find a link to a more readable format of my V Mag Pop Culture Column on http://t.co/ekIJBXo My new blog!"]
這裏是整個JSON看起來像作爲散列的紅寶石陣列(截斷堆棧溢出):
[{"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Quito",
"friends_count"=>142497,
"protected"=>false,
"location"=>"New York, NY",
"is_translator"=>false,
"following"=>true,
"profile_use_background_image"=>true,
"name"=>"Lady Gaga",
"follow_request_sent"=>false,
"statuses_count"=>968,
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"default_profile"=>false,
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"profile_text_color"=>"333333",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"listed_count"=>208144,
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"contributors_enabled"=>false,
"lang"=>"en",
"profile_background_tile"=>true,
"followers_count"=>11781463,
"screen_name"=>"ladygaga",
"id_str"=>"14230524",
"profile_link_color"=>"0084B4",
"id"=>14230524,
"default_profile_image"=>false,
"show_all_inline_media"=>false,
"geo_enabled"=>false,
"notifications"=>true,
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Tue Jul 19 18:09:40 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"Here's my LIVE radio performance on the Howard Stern Show! http://bit.ly/pighVL\"",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"user_mentions"=>[],
"urls"=>
[{"url"=>"http://bit.ly/pighVL",
"indices"=>[59, 79],
"expanded_url"=>nil}],
"hashtags"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"93382007496769536",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>93382007496769536},
{"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Quito",
"protected"=>false,
"location"=>"New York, NY",
"contributors_enabled"=>false,
"following"=>true,
"profile_use_background_image"=>true,
"name"=>"Lady Gaga",
"default_profile_image"=>false,
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"default_profile"=>false,
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"friends_count"=>142497,
"is_translator"=>false,
"show_all_inline_media"=>false,
"geo_enabled"=>false,
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"follow_request_sent"=>false,
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"lang"=>"en",
"statuses_count"=>968,
"profile_background_tile"=>true,
"followers_count"=>11781456,
"screen_name"=>"ladygaga",
"id_str"=>"14230524",
"listed_count"=>208145,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"profile_link_color"=>"0084B4",
"id"=>14230524,
"notifications"=>false,
"profile_sidebar_border_color"=>"BDDCAD",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg"},
"created_at"=>"Tue Jul 19 17:51:11 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"Thanks baby. I'm a die hard monsterfan [email protected]: @ladygaga 's album speaks to me more than any other album ever. #diehardfan",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[{"indices"=>[115, 126], "text"=>"diehardfan"}],
"user_mentions"=>
[{"name"=>"Lady Gaga",
"indices"=>[50, 59],
"screen_name"=>"ladygaga",
"id_str"=>"14230524",
"id"=>14230524}],
"urls"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"93377358974812161",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>93377358974812161},
{"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Quito",
"protected"=>false,
"location"=>"New York, NY",
"listed_count"=>208144,
"following"=>false,
"profile_use_background_image"=>true,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"name"=>"Lady Gaga",
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"default_profile"=>false,
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"contributors_enabled"=>false,
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"default_profile_image"=>false,
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"friends_count"=>142497,
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"is_translator"=>false,
"show_all_inline_media"=>false,
"lang"=>"en",
"geo_enabled"=>false,
"profile_background_tile"=>true,
"followers_count"=>11781392,
"screen_name"=>"ladygaga",
"follow_request_sent"=>false,
"id_str"=>"14230524",
"profile_link_color"=>"0084B4",
"id"=>14230524,
"statuses_count"=>968,
"notifications"=>false,
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Mon Jul 18 14:30:46 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"http://twitpic.com/5s4f2h - Just left @HowardStern, rockers with long hair have a sweetspot for girls like me. He was a doll. :)",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[],
"user_mentions"=>
[{"name"=>"Howard Stern",
"indices"=>[38, 50],
"screen_name"=>"HowardStern",
"id_str"=>"246481013",
"id"=>246481013}],
"urls"=>
[{"url"=>"http://twitpic.com/5s4f2h",
"indices"=>[0, 25],
"expanded_url"=>nil}]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"92964531315294209",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92964531315294209},
{"in_reply_to_status_id"=>nil,
"user"=>
{"follow_request_sent"=>false,
"time_zone"=>"Quito",
"protected"=>false,
"location"=>"New York, NY",
"show_all_inline_media"=>false,
"following"=>true,
"geo_enabled"=>false,
"profile_use_background_image"=>true,
"name"=>"Lady Gaga",
"default_profile"=>false,
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"listed_count"=>208146,
"statuses_count"=>968,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"profile_text_color"=>"333333",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"contributors_enabled"=>false,
"lang"=>"en",
"profile_background_tile"=>true,
"followers_count"=>11781425,
"screen_name"=>"ladygaga",
"default_profile_image"=>false,
"id_str"=>"14230524",
"friends_count"=>142497,
"profile_link_color"=>"0084B4",
"id"=>14230524,
"is_translator"=>false,
"notifications"=>false,
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Mon Jul 18 11:24:18 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"SURPRISE MONSTERS! You can find a link to a more readable format of my V Mag Pop Culture Column on http://t.co/ekIJBXo My new blog!",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"user_mentions"=>[],
"urls"=>
[{"url"=>"http://t.co/ekIJBXo",
"display_url"=>"tinyurl.com/3p42npn",
"indices"=>[99, 118],
"expanded_url"=>"http://tinyurl.com/3p42npn"}],
"hashtags"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>"web",
"id_str"=>"92917605253386241",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92917605253386241},
{"in_reply_to_status_id"=>nil,
"user"=>
{"contributors_enabled"=>false,
"time_zone"=>"Quito",
"protected"=>false,
"location"=>"New York, NY",
"default_profile"=>false,
"following"=>false,
"profile_use_background_image"=>true,
"name"=>"Lady Gaga",
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"is_translator"=>false,
"default_profile_image"=>false,
"verified"=>true,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"show_all_inline_media"=>false,
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"friends_count"=>142497,
"geo_enabled"=>false,
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"follow_request_sent"=>false,
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"lang"=>"en",
"profile_background_tile"=>true,
"followers_count"=>11781014,
"screen_name"=>"ladygaga",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"id_str"=>"14230524",
"profile_link_color"=>"0084B4",
"id"=>14230524,
"listed_count"=>208145,
"statuses_count"=>968,
"notifications"=>false,
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Mon Jul 18 10:35:37 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"http://twitpic.com/5s1f29 - If you need a quick fashion read, here's my V Mag column for the month. This time we did a Triptych!",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[],
"user_mentions"=>[],
"urls"=>
[{"url"=>"http://twitpic.com/5s1f29",
"indices"=>[0, 25],
"expanded_url"=>nil}]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"92905355444621313",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92905355444621313},
{"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Quito",
"protected"=>false,
"location"=>"New York, NY",
"is_translator"=>false,
"following"=>true,
"profile_use_background_image"=>true,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"name"=>"Lady Gaga",
"follow_request_sent"=>false,
"friends_count"=>142497,
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"default_profile"=>false,
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"show_all_inline_media"=>false,
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"listed_count"=>208145,
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"lang"=>"en",
"geo_enabled"=>false,
"profile_background_tile"=>true,
"followers_count"=>11780972,
"screen_name"=>"ladygaga",
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"id_str"=>"14230524",
"statuses_count"=>968,
"profile_link_color"=>"0084B4",
"id"=>14230524,
"default_profile_image"=>false,
"contributors_enabled"=>false,
"notifications"=>false,
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Sun Jul 17 22:50:49 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"I'm live with @howardstern 2moro morning on Sirius XM. Big fan. Gonna sing my face off, and talk shit w the raddest Hair in radio. 8am EDT",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[],
"user_mentions"=>
[{"name"=>"Howard Stern",
"indices"=>[14, 26],
"screen_name"=>"HowardStern",
"id_str"=>"246481013",
"id"=>246481013}],
"urls"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"92727984666066944",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92727984666066944},
{"retweeted_status"=>
{"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Central Time (US & Canada)",
"protected"=>false,
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1395256604/DSCN06191_normal.jpg",
"location"=>"USA",
"default_profile_image"=>false,
"show_all_inline_media"=>false,
"following"=>false,
"geo_enabled"=>true,
"profile_use_background_image"=>true,
"name"=>"John Marshall",
"contributors_enabled"=>false,
"profile_background_color"=>"709397",
"url"=>nil,
"is_translator"=>false,
"verified"=>false,
"profile_background_image_url"=>
"http://a1.twimg.com/images/themes/theme6/bg.gif",
"utc_offset"=>-21600,
"follow_request_sent"=>false,
"statuses_count"=>849,
"favourites_count"=>0,
"created_at"=>"Mon Mar 07 03:52:21 +0000 2011",
"friends_count"=>423,
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a0.twimg.com/profile_images/1395256604/DSCN06191_normal.jpg",
"profile_sidebar_fill_color"=>"A0C5C7",
"description"=>
"420 #BoardsofCanada #GLP #iamamiwhoami #M\u00FCtterMons\u2020re Say what you say, do what you do, feel what you feel, as long as it's real.",
"lang"=>"en",
"profile_background_tile"=>false,
"followers_count"=>583,
"screen_name"=>"Karczochy",
"listed_count"=>5,
"id_str"=>"261997342",
"profile_link_color"=>"FF3300",
"id"=>261997342,
"default_profile"=>false,
"notifications"=>false,
"profile_background_image_url_https"=>
"https://si0.twimg.com/images/themes/theme6/bg.gif",
"profile_sidebar_border_color"=>"86A4A6"},
"created_at"=>"Sun Jul 17 21:36:45 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"LOL. That's gonna be..interesting..RT @jeff1317 Howard Stern is back tomorrow and @ladygaga is a guest! Should make for great radio!",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[],
"user_mentions"=>
[{"name"=>"Jeff",
"indices"=>[38, 47],
"screen_name"=>"jeff1317",
"id_str"=>"22542097",
"id"=>22542097},
{"name"=>"Lady Gaga",
"indices"=>[82, 91],
"screen_name"=>"ladygaga",
"id_str"=>"14230524",
"id"=>14230524}],
"urls"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>false,
"source"=>
"<a href=\"http://twitter.com/#!/download/ipad\" rel=\"nofollow\">Twitter for iPad</a>",
"id_str"=>"92709349004279809",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92709349004279809},
"in_reply_to_status_id"=>nil,
"user"=>
{"time_zone"=>"Quito",
"protected"=>false,
"profile_image_url_https"=>
"https://si0.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"location"=>"New York, NY",
"default_profile_image"=>false,
"show_all_inline_media"=>false,
"following"=>false,
"geo_enabled"=>false,
"profile_use_background_image"=>true,
"name"=>"Lady Gaga",
"contributors_enabled"=>false,
"profile_background_color"=>"9AE4E8",
"url"=>"http://www.ladygaga.com",
"is_translator"=>false,
"verified"=>true,
"profile_background_image_url"=>
"http://a1.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"utc_offset"=>-18000,
"follow_request_sent"=>false,
"statuses_count"=>968,
"favourites_count"=>2,
"created_at"=>"Wed Mar 26 22:37:48 +0000 2008",
"friends_count"=>142497,
"profile_text_color"=>"333333",
"profile_image_url"=>
"http://a1.twimg.com/profile_images/1239447061/Unnamed-1_normal.jpg",
"profile_sidebar_fill_color"=>"DDFFCC",
"description"=>"mother mons\u2020er\r\n",
"lang"=>"en",
"profile_background_tile"=>true,
"followers_count"=>11781095,
"screen_name"=>"ladygaga",
"listed_count"=>208145,
"id_str"=>"14230524",
"profile_link_color"=>"0084B4",
"id"=>14230524,
"default_profile"=>false,
"notifications"=>false,
"profile_background_image_url_https"=>
"https://si0.twimg.com/profile_background_images/203383875/Unnamed-1.jpg",
"profile_sidebar_border_color"=>"BDDCAD"},
"created_at"=>"Sun Jul 17 21:38:16 +0000 2011",
"geo"=>nil,
"in_reply_to_user_id"=>nil,
"favorited"=>false,
"text"=>
"RT @Karczochy: LOL. That's gonna be..interesting..RT @jeff1317 Howard Stern is back tomorrow and @ladygaga is a guest! Should make for g ...",
"in_reply_to_status_id_str"=>nil,
"entities"=>
{"hashtags"=>[],
"user_mentions"=>
[{"name"=>"John Marshall",
"indices"=>[3, 13],
"screen_name"=>"Karczochy",
"id_str"=>"261997342",
"id"=>261997342},
{"name"=>"Jeff",
"indices"=>[53, 62],
"screen_name"=>"jeff1317",
"id_str"=>"22542097",
"id"=>22542097},
{"name"=>"Lady Gaga",
"indices"=>[97, 106],
"screen_name"=>"ladygaga",
"id_str"=>"14230524",
"id"=>14230524}],
"urls"=>[]},
"in_reply_to_screen_name"=>nil,
"in_reply_to_user_id_str"=>nil,
"place"=>nil,
"coordinates"=>nil,
"truncated"=>true,
"source"=>
"<a href=\"http://blackberry.com/twitter\" rel=\"nofollow\">Twitter for BlackBerry\u00AE</a>",
"id_str"=>"92709727896735745",
"contributors"=>nil,
"retweeted"=>false,
"retweet_count"=>"100+",
"id"=>92709727896735745},
是有辦法讓'doc'格式化更好?你究竟是什麼意思「實際div加載之後通過JavaScript的Twitter API」。 –
沒有辦法與nokogiri做到這一點,因爲nokogiri無法解析ajax請求的結果。你爲什麼需要它?大概你可以使用twitter api。 – NARKOZ
@Justin NARKOZ的含義是,如果你「查看源代碼」(並且不檢查元素),你會發現你聲明的HTML在原始HTTP響應中並不存在。相反,JavaScript代碼在網站上運行,並最終從11(!)個不同的XHR JSON請求中獲得內容。 JavaScript然後用這些類動態地在頁面上構建元素。 Nokogiri不是一個完整的Web瀏覽器,並且不運行JavaScript。 – Phrogz