Skip to content

Instantly share code, notes, and snippets.

@knapply
Created September 22, 2020 17:50
Show Gist options
  • Save knapply/fdbd4991a289bc7ae869573917b09bef to your computer and use it in GitHub Desktop.
Save knapply/fdbd4991a289bc7ae869573917b09bef to your computer and use it in GitHub Desktop.
Scrape MCCs and MNCs
get_mcc_mnc <- function() {
target_url <- "http://mcc-mnc.com/"
init <- xml2::read_html(target_url)
table_node <- rvest::html_node(init, "table")
out <- rvest::html_table(table_node)
out$MNC[out$MNC == "n/a"] <- NA_character_
out$MNC <- as.integer(out$MNC)
out
}
print(tibble::as_tibble(get_mcc_mnc()), n = 100)
#> # A tibble: 1,690 x 6
#> MCC MNC ISO Country `Country Code` Network
#> <int> <int> <chr> <chr> <int> <chr>
#> 1 289 88 ge Abkhazia 7 A-Mobile
#> 2 289 68 ge Abkhazia 7 A-Mobile
#> 3 289 67 ge Abkhazia 7 Aquafon
#> 4 412 88 af Afghanistan 93 Afghan Telecom Corp. (AT)
#> 5 412 80 af Afghanistan 93 Afghan Telecom Corp. (AT)
#> 6 412 1 af Afghanistan 93 Afghan Wireless/AWCC
#> 7 412 40 af Afghanistan 93 Areeba/MTN
#> 8 412 30 af Afghanistan 93 Etisalat
#> 9 412 50 af Afghanistan 93 Etisalat
#> 10 412 20 af Afghanistan 93 Roshan/TDCA
#> 11 412 3 af Afghanistan 93 WaselTelecom (WT)
#> 12 276 1 al Albania 355 AMC/Cosmote
#> 13 276 3 al Albania 355 Eagle Mobile
#> 14 276 4 al Albania 355 PLUS Communication Sh.a
#> 15 276 2 al Albania 355 Vodafone
#> 16 603 1 dz Algeria 213 ATM Mobils
#> 17 603 2 dz Algeria 213 Orascom / DJEZZY
#> 18 603 3 dz Algeria 213 Oreedo/Wataniya / Nedjma
#> 19 544 11 as American Samoa 684 Blue Sky Communications
#> 20 213 3 ad Andorra 376 Mobiland
#> 21 631 4 ao Angola 244 MoviCel
#> 22 631 2 ao Angola 244 Unitel
#> 23 365 840 ai Anguilla 1264 Cable and Wireless
#> 24 365 10 ai Anguilla 1264 Digicell / Wireless Vent. L…
#> 25 344 30 ag Antigua and B… 1268 APUA PCS
#> 26 344 920 ag Antigua and B… 1268 C & W
#> 27 344 930 ag Antigua and B… 1268 DigiCel/Cing. Wireless
#> 28 722 310 ar Argentina Rep… 54 Claro/ CTI/AMX
#> 29 722 330 ar Argentina Rep… 54 Claro/ CTI/AMX
#> 30 722 320 ar Argentina Rep… 54 Claro/ CTI/AMX
#> 31 722 10 ar Argentina Rep… 54 Compania De Radiocomunicaci…
#> 32 722 70 ar Argentina Rep… 54 Movistar/Telefonica
#> 33 722 20 ar Argentina Rep… 54 Nextel
#> 34 722 341 ar Argentina Rep… 54 Telecom Personal S.A.
#> 35 722 340 ar Argentina Rep… 54 Telecom Personal S.A.
#> 36 283 1 am Armenia 374 ArmenTel/Beeline
#> 37 283 4 am Armenia 374 Karabakh Telecom
#> 38 283 10 am Armenia 374 Orange
#> 39 283 5 am Armenia 374 Vivacell
#> 40 363 2 aw Aruba 297 Digicel
#> 41 363 20 aw Aruba 297 Digicel
#> 42 363 1 aw Aruba 297 Setar GSM
#> 43 505 14 au Australia 61 AAPT Ltd.
#> 44 505 24 au Australia 61 Advanced Comm Tech Pty.
#> 45 505 9 au Australia 61 Airnet Commercial Australia…
#> 46 505 4 au Australia 61 Department of Defense
#> 47 505 26 au Australia 61 Dialogue Communications Pty…
#> 48 505 12 au Australia 61 H3G Ltd.
#> 49 505 6 au Australia 61 H3G Ltd.
#> 50 505 88 au Australia 61 Localstar Holding Pty. Ltd
#> 51 505 19 au Australia 61 Lycamobile Pty Ltd
#> 52 505 8 au Australia 61 Railcorp/Vodafone
#> 53 505 99 au Australia 61 Railcorp/Vodafone
#> 54 505 13 au Australia 61 Railcorp/Vodafone
#> 55 505 90 au Australia 61 Singtel Optus
#> 56 505 2 au Australia 61 Singtel Optus
#> 57 505 1 au Australia 61 Telstra Corp. Ltd.
#> 58 505 71 au Australia 61 Telstra Corp. Ltd.
#> 59 505 11 au Australia 61 Telstra Corp. Ltd.
#> 60 505 72 au Australia 61 Telstra Corp. Ltd.
#> 61 505 5 au Australia 61 The Ozitel Network Pty.
#> 62 505 16 au Australia 61 Victorian Rail Track Corp. …
#> 63 505 7 au Australia 61 Vodafone
#> 64 505 3 au Australia 61 Vodafone
#> 65 232 11 at Austria 43 A1 MobilKom
#> 66 232 2 at Austria 43 A1 MobilKom
#> 67 232 9 at Austria 43 A1 MobilKom
#> 68 232 1 at Austria 43 A1 MobilKom
#> 69 232 15 at Austria 43 T-Mobile/Telering
#> 70 232 10 at Austria 43 H3G
#> 71 232 14 at Austria 43 H3G
#> 72 232 5 at Austria 43 3/Orange/One Connect
#> 73 232 12 at Austria 43 3/Orange/One Connect
#> 74 232 6 at Austria 43 3/Orange/One Connect
#> 75 232 17 at Austria 43 Spusu/Mass Response
#> 76 232 7 at Austria 43 T-Mobile/Telering
#> 77 232 4 at Austria 43 T-Mobile/Telering
#> 78 232 3 at Austria 43 T-Mobile/Telering
#> 79 232 19 at Austria 43 Tele2
#> 80 232 8 at Austria 43 A1 MobilKom
#> 81 232 13 at Austria 43 UPC Austria
#> 82 400 1 az Azerbaijan 994 Azercell Telekom B.M.
#> 83 400 4 az Azerbaijan 994 Azerfon.
#> 84 400 3 az Azerbaijan 994 Caspian American Telecommun…
#> 85 400 2 az Azerbaijan 994 J.V. Bakcell GSM 2000
#> 86 364 30 bs Bahamas 1242 Bahamas Telco. Comp.
#> 87 364 390 bs Bahamas 1242 Bahamas Telco. Comp.
#> 88 364 39 bs Bahamas 1242 Bahamas Telco. Comp.
#> 89 364 3 bs Bahamas 1242 Smart Communications
#> 90 426 1 bh Bahrain 973 Batelco
#> 91 426 2 bh Bahrain 973 ZAIN/Vodafone
#> 92 426 4 bh Bahrain 973 VIVA
#> 93 470 2 bd Bangladesh 880 Robi/Aktel
#> 94 470 5 bd Bangladesh 880 Citycell
#> 95 470 6 bd Bangladesh 880 Citycell
#> 96 470 1 bd Bangladesh 880 GrameenPhone
#> 97 470 3 bd Bangladesh 880 Orascom/Banglalink
#> 98 470 4 bd Bangladesh 880 TeleTalk
#> 99 470 7 bd Bangladesh 880 Airtel/Warid
#> 100 342 600 bb Barbados 1246 LIME
#> # … with 1,590 more rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment