Skip to content

Instantly share code, notes, and snippets.

@betzerra
Last active May 15, 2020 20:35
Show Gist options
  • Save betzerra/4b3766463292b75d477e9819c0adede6 to your computer and use it in GitHub Desktop.
Save betzerra/4b3766463292b75d477e9819c0adede6 to your computer and use it in GitHub Desktop.
COVID-19
require 'nokogiri'
require 'faraday'
require 'pry'
conn = Faraday.new
response = conn.get 'https://www.worldometers.info/coronavirus/'
covid_page = Nokogiri::HTML(response.body)
puts '"Country";"Infected";"Deaths";"ID ratio"'
covid_page.css('.mt_a').each do |c|
infected = c.parent.parent.css('td')[2].text.delete(',').to_i
deaths = c.parent.parent.css('td')[4].text.delete(',').to_i
next if deaths.to_i.zero?
puts "\"#{c.text}\";#{infected};#{deaths};#{(deaths.to_f / infected.to_f).round(3)}"
# binding.pry
end
Country Infected Deaths ID ratio
USA 1477229 88110 0.06
Spain 274367 27459 0.1
Russia 262843 2418 0.009
UK 236711 33998 0.144
Italy 223885 31610 0.141
Brazil 212198 14455 0.068
France 178870 27529 0.154
Germany 175388 7951 0.045
Turkey 146457 4055 0.028
Iran 116635 6902 0.059
India 85784 2753 0.032
Peru 84495 2392 0.028
Canada 74532 5553 0.075
Belgium 54644 8959 0.164
Saudi Arabia 49176 292 0.006
Netherlands 43681 5643 0.129
Mexico 42595 4477 0.105
Chile 39542 394 0.01
Pakistan 37218 803 0.022
Ecuador 31467 2594 0.082
Switzerland 30514 1878 0.062
Qatar 29425 14 0.0
Sweden 29207 3646 0.125
Portugal 28583 1190 0.042
Belarus 27730 156 0.006
Singapore 26891 21 0.001
Ireland 23956 1518 0.063
UAE 21831 210 0.01
Bangladesh 20065 298 0.015
Poland 18016 907 0.05
Ukraine 17330 476 0.027
Israel 16589 266 0.016
Indonesia 16496 1076 0.065
Romania 16437 1070 0.065
Japan 16120 697 0.043
Austria 16109 628 0.039
Colombia 13610 525 0.039
South Africa 13524 247 0.018
Kuwait 12860 96 0.007
Philippines 12091 806 0.067
Dominican Republic 11739 424 0.036
Egypt 11228 592 0.053
S. Korea 11018 260 0.024
Denmark 10791 537 0.05
Serbia 10438 225 0.022
Panama 9118 260 0.029
Czechia 8374 295 0.035
Norway 8206 232 0.028
Argentina 7134 353 0.049
Australia 7019 98 0.014
Malaysia 6855 112 0.016
Morocco 6652 190 0.029
Algeria 6629 536 0.081
Bahrain 6582 10 0.002
Finland 6228 293 0.047
Afghanistan 6053 153 0.025
Moldova 5745 202 0.035
Kazakhstan 5689 34 0.006
Ghana 5530 24 0.004
Nigeria 5162 167 0.032
Oman 4625 20 0.004
Armenia 4044 52 0.013
Luxembourg 3923 104 0.027
Hungary 3417 442 0.129
Bolivia 3372 152 0.045
Iraq 3193 117 0.037
Thailand 3025 56 0.019
Azerbaijan 2980 36 0.012
Cameroon 2954 139 0.047
Greece 2810 160 0.057
Uzbekistan 2686 11 0.004
Guinea 2473 15 0.006
Honduras 2318 133 0.057
Senegal 2310 25 0.011
Bosnia and Herzegovina 2236 128 0.057
Croatia 2222 95 0.043
Bulgaria 2138 102 0.048
Ivory Coast 1971 24 0.012
Sudan 1964 91 0.046
Cuba 1840 79 0.043
Iceland 1802 10 0.006
Estonia 1766 63 0.036
North Macedonia 1740 97 0.056
Lithuania 1523 54 0.035
Guatemala 1518 29 0.019
New Zealand 1498 21 0.014
Slovakia 1480 27 0.018
Slovenia 1465 103 0.07
Djibouti 1309 4 0.003
DRC 1298 50 0.039
Somalia 1284 53 0.041
El Salvador 1210 23 0.019
Mayotte 1210 16 0.013
Tajikistan 1118 33 0.03
Kyrgyzstan 1111 14 0.013
Gabon 1104 10 0.009
Hong Kong 1053 4 0.004
Tunisia 1032 45 0.044
Maldives 1020 4 0.004
Latvia 970 19 0.02
Sri Lanka 935 9 0.01
Albania 916 31 0.034
Guinea-Bissau 913 3 0.003
Cyprus 910 17 0.019
Lebanon 891 26 0.029
Niger 876 50 0.057
Costa Rica 843 8 0.009
Mali 806 46 0.057
Kenya 781 45 0.058
Burkina Faso 780 51 0.065
Andorra 761 49 0.064
Paraguay 759 11 0.014
Uruguay 724 19 0.026
Georgia 671 12 0.018
Zambia 654 7 0.011
San Marino 652 41 0.063
Jordan 596 9 0.015
Equatorial Guinea 594 7 0.012
Channel Islands 549 43 0.078
Malta 532 6 0.011
Tanzania 509 21 0.041
Jamaica 509 9 0.018
Venezuela 455 10 0.022
Sierra Leone 447 27 0.06
Taiwan 440 7 0.016
Chad 428 48 0.112
Congo 391 15 0.038
Palestine 375 2 0.005
Benin 339 2 0.006
Isle of Man 334 24 0.072
Mauritius 332 10 0.03
Cabo Verde 326 2 0.006
Montenegro 324 9 0.028
Ethiopia 287 5 0.017
Haiti 273 20 0.073
Togo 238 11 0.046
Sao Tome and Principe 235 7 0.03
South Sudan 231 1 0.004
Liberia 219 20 0.091
Eswatini 190 2 0.011
Martinique 189 14 0.074
Myanmar 181 6 0.033
French Guiana 164 1 0.006
Guadeloupe 155 13 0.084
Brunei 141 1 0.007
Bermuda 122 9 0.074
Trinidad and Tobago 116 8 0.069
Guyana 113 10 0.088
Yemen 106 15 0.142
Aruba 101 3 0.03
Bahamas 96 11 0.115
Monaco 96 4 0.042
Cayman Islands 93 1 0.011
Barbados 85 7 0.082
Liechtenstein 82 1 0.012
Sint Maarten 76 15 0.197
Libya 64 3 0.047
Malawi 63 3 0.048
Syria 50 3 0.06
Angola 48 2 0.042
Zimbabwe 42 4 0.095
Saint Martin 39 3 0.077
Mauritania 26 2 0.077
Nicaragua 25 8 0.32
Antigua and Barbuda 25 3 0.12
Botswana 24 1 0.042
Gambia 23 1 0.043
Belize 18 2 0.111
Curaçao 16 1 0.063
Burundi 15 1 0.067
Turks and Caicos 12 1 0.083
Comoros 11 1 0.091
Montserrat 11 1 0.091
Suriname 10 1 0.1
British Virgin Islands 8 1 0.125
China 82933 4633 0.056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment