Skip to content

Instantly share code, notes, and snippets.

@sdilshod
Created February 6, 2017 19:19
Show Gist options
  • Save sdilshod/eb8f1832db7d0204560109b9de7cf329 to your computer and use it in GitHub Desktop.
Save sdilshod/eb8f1832db7d0204560109b9de7cf329 to your computer and use it in GitHub Desktop.
data_result = [["US - 258024 K", "Kg.", "<tbody> <tr> <th> VIBRACOUSTIC </th> <td> VI0058024 </td> </tr> </tbody>", "<tbody> <tr> <th> </th> <td> 7421821030 </td> </tr> </tbody>", "http://www.usmerkaucuk.com/products/details/c/74", "US - 258024 K.png"], ["US - 200907", "0,5 Kg.", "<tbody> <tr> <th> CONTITECH </th> <td> SZ828 </td> </tr> <tr> <th> AIRKRAFT </th> <td> 125122 </td> </tr> </tbody>", "<tbody> </tbody>", "http://www.usmerkaucuk.com/products/details/c/90", "US - 200907.png"]]
data_result.each do |row|
crosses = []
(2..3).each do |t|
html_doc = Nokogiri::HTML(row[t])
table_rows = html_doc.search('tbody tr')
make_name = table_rows[0].blank? ? '' : table_rows[0].text
oem = table_rows[1].blank? ? '' : table_rows[1].text
crosses << [ make_name, oem ] # массив вида ["Производитель", "Номер"]
end
puts crosses
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment