1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'open-uri'

cached_nodes = [1, 5, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 23, 26, 28, 31, 32, 33, 34, 37, 38, 40, 41, 44, 47, 48, 49, 54, 55, 56, 58, 60, 61, 63, 66, 71, 73, 74, 75, 76, 78, 81, 82, 83, 86, 88, 91, 92, 93, 94, 98, 99, 100, 101, 103, 104, 106, 107, 108, 112, 113, 114, 115, 116, 119, 120, 121, 122, 123, 124, 125, 126, 127, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 149, 150, 151, 152, 153, 155, 156, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 170, 171, 172, 175, 177, 179, 180, 182, 184, 186, 189, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 206, 207, 210, 213, 214, 215, 216, 219, 222, 224, 226, 227, 228, 229, 230, 231, 233, 234, 237, 240, 241, 244, 245, 247, 248, 249, 251, 252, 253, 254, 255, 256, 257, 259, 260, 262, 263, 264, 265, 266, 275, 277, 281, 284, 286, 288, 290, 291, 294, 299, 301, 305, 306, 312, 313, 315, 320, 322, 325, 328, 331, 332, 333, 337, 338, 339, 341, 342, 344, 346, 347, 348, 349, 350, 351, 352, 354, 355, 363, 365, 366, 373, 379, 381, 383, 384, 387, 389, 390, 393, 394, 395, 405, 407, 412, 414, 418, 420, 422, 425, 427, 428, 429, 432, 434, 438, 440, 441, 442, 448, 449, 450, 451, 452, 454, 455, 456, 457, 461, 463, 464, 466, 467, 480, 481, 482, 483, 487, 489, 490, 495, 496, 499, 501, 504, 507, 511, 513, 519, 524, 526, 528, 529, 532, 533, 535, 536, 538, 539, 540, 544, 545, 546, 547, 550, 551, 552, 553, 554, 557, 561, 564, 565, 566, 567, 568, 569, 570, 572, 579, 581, 584, 590, 591, 592, 593, 594, 599, 602, 604, 606, 607, 609, 610, 611, 613, 615, 618, 623, 624, 625, 628, 633, 634, 635, 640, 643, 646, 652, 658, 668, 671, 672, 673, 678, 680, 684, 686, 689, 690, 693, 694, 696, 706, 712, 715, 719, 720, 723, 728, 729, 730, 732, 733, 734, 735, 737, 738, 739, 745, 752, 758, 759, 761, 766, 767, 769, 773, 774, 778, 786, 787, 788, 792, 794, 798, 799, 809, 812, 814, 815, 820, 822, 823, 824, 826, 829, 830, 836, 839, 842, 843, 846, 858, 860, 864, 868, 870, 874, 879, 885, 887, 888, 903, 904, 906, 912, 915, 920, 922, 926, 930, 934, 939, 940, 948, 950, 958, 964, 965, 968, 973, 981, 984, 985, 986, 990, 999, 1002, 1003, 1005, 1006, 1007, 1008, 1012, 1013, 1014, 1018, 1019, 1024, 1026, 1027, 1028, 1029, 1035, 1039, 1040, 1043, 1044, 1046, 1049, 1050, 1052, 1054, 1056, 1066, 1072, 1078, 1079, 1084, 1091, 1095, 1097, 1105, 1106, 1109, 1110, 1127, 1128, 1131, 1142, 1144, 1149, 1156, 1159, 1163, 1167, 1168, 1173, 1177, 1186, 1189, 1190, 1193, 1201, 1203, 1215, 1225, 1231, 1235, 1245, 1246, 1249, 1251, 1252, 1253, 1290, 1294, 1315, 1322, 1325, 1331, 1339, 1345, 1375, 1384, 1386, 1387, 1398, 1400, 1401, 1408, 1414, 1423, 1425, 1432, 1441, 1456, 1470, 1495, 1496, 1514, 1518, 1546, 1557, 1561, 1602, 1605, 1611, 1613, 1630, 1634, 1638, 1646, 1649, 1657, 1663, 1667, 1668, 1669, 1671, 1673, 1675, 1678, 1682, 1683, 1685, 1687, 1688, 1691, 1702, 1703, 1705, 1707, 1708, 1714, 1715, 1717, 1718, 1725, 1726, 1727, 1730, 1733, 1736, 1738, 1740, 1741, 1742, 1743, 1745, 1749, 1753, 1754, 1756]

cached_nodes.each do |i|
  if i > 0
    g = open('http://www.google.com/search?q=redacted_base_url' + i.to_s).read
    if g =~ /Cached/
      m = g.match(%r-<a class=fl href="http.*?">Cached-)[0]
      m.sub!(/^<a class=fl href="/, "")
      m.sub!(/">Cached$/, "")

      s = open(m).read
      t = s.match(%r-<title>(.*?)</title>-)[1]
      t.gsub!(/\\/, "")
      t.gsub!(/\//, "")
      t.gsub!(/:/, "")
      t.gsub!(/<.*?>/, "")

      File.open("nodes/#{i} - #{t}.html", "w") {|f| f.write s}
      p i
    else
      p "no cache for #{i}"
    end
    # exit if i > 20
  end
end