Skip to content

Instantly share code, notes, and snippets.

@kirsn

kirsn/test_tld.py

Last active Aug 29, 2015
Embed
What would you like to do?
A quick test to test the tld module: https://github.com/barseghyanartur/tld
"""
A test to see whether the tld module recognizes all the valid domains.
"""
import requests # http://docs.python-requests.org/en/latest/
import tld # https://pypi.python.org/pypi/tld
# Mozilla curated db of tlds. Used by tld module
tlds = requests.get("https://publicsuffix.org/list/effective_tld_names.dat")
valid_urls = 0
invalid_urls = 0
invalid_domains = ""
print("<html><body>")
print("<h2>%s</h2>" %
"Domains NOT recognized by tld module, though the domain is VALID")
for line in tlds.text.split('\n'):
# Ignore lines with comments, or empty spaces
if line.startswith("//") == False and len(line.strip()) > 0:
url = "http://test." + line.strip()
try:
tld.get_tld(url)
valid_urls += 1
except tld.exceptions.TldDomainNotFound:
invalid_urls += 1
invalid_domains += "%s, " % line.encode(
'ascii', 'xmlcharrefreplace')
print(invalid_domains)
print("<h2>Some numbers</h2>")
print("<b>Invalid Domains according to the <i>tld module</i>: %d</b>" %
invalid_urls)
print("Valid domains according to the <i>tld module</i>: %d" %
valid_urls)
print("</body></html>")
@kirsn

This comment has been minimized.

Copy link
Owner Author

@kirsn kirsn commented Feb 4, 2015

Domains NOT recognized by tld module, though the domain is VALID

arpa, bv, cw, com.cw, edu.cw, net.cw, org.cw, gb, gn, kp, com.kp, edu.kp, gov.kp, org.kp, rep.kp, tra.kp, lb, lr, ng, name.ng, sch.ng, mil.ng, mobi.ng, pm, post, sa, sj, so, com.so, net.so, org.so, sx, gov.sx, tp, tz, hotel.tz, info.tz, me.tz, mil.tz, mobi.tz, sc.tz, tv.tz, wf, yt, امارات, বাংলা, 中国, 中國, الجزائر, مصر, გე, 香港, भारत, بھارت, భారత్, ભારત, ਭਾਰਤ, ভারত, இந்தியா, ایران, ايران, الاردن, 한국, қаз, ලංකා, இலங்கை, المغرب, мон, مليسيا, عمان, فلسطين, срб, пр.срб, орг.срб, обр.срб, од.срб, упр.срб, ак.срб, рф, قطر, السعودية, السعودیة, السعودیۃ, السعوديه, سورية, سوريا, 新加坡, சிங்கப்பூர், ไทย, تونس, 台灣, 台湾, 臺灣, укр, اليمن, xxx, abb, abbott, abogado, academy, accenture, accountant, accountants, active, actor, ads, adult, afl, africa, agency, aig, airforce, airtel, allfinanz, alsace, amsterdam, analytics, android, apartments, aquarelle, aramco, archi, army, arte, associates, attorney, auction, audio, author, auto, autos, axa, azure, band, bank, bar, barcelona, barclaycard, barclays, bargains, bauhaus, bayern, bbc, bbva, bcn, beer, bentley, berlin, best, bharti, bible, bid, bike, bing, bingo, bio, black, blackfriday, bloomberg, blue, bms, bmw, bnl, bnpparibas, boats, bom, bond, boo, bot, boutique, bradesco, bridgestone, broker, brussels, budapest, build, builders, business, buy, buzz, bzh, cab, cal, call, camera, camp, cancerresearch, canon, capetown, capital, caravan, cards, care, career, careers, cars, cartier, casa, cash, casino, catering, cba, cbn, center, ceo, cern, cfa, cfd, channel, chat, cheap, chloe, christmas, chrome, church, circle, citic, city, cityeats, claims, cleaning, click, clinic, clothing, club, coach, codes, coffee, college, cologne, commbank, community, company, computer, condos, construction, consulting, contractors, cooking, cool, corsica, country, courses, credit, creditcard, cricket, crown, crs, cruises, csc, cuisinella, cymru, dabur, dad, dance, date, dating, datsun, day, dclk, deals, degree, delivery, dell, democrat, dental, dentist, desi, design, dev, diamonds, diet, digital, direct, directory, discount, dnp, docs, dog, doha, domains, doosan, download, durban, dvag, earth, eat, edeka, education, email, emerck, energy, engineer, engineering, enterprises, epson, equipment, erni, esq, estate, eurovision, eus, events, everbank, exchange, expert, exposed, fage, fail, fairwinds, faith, fan, fans, farm, fashion, fast, feedback, ferrero, final, finance, financial, firestone, firmdale, fish, fishing, fit, fitness, flights, florist, flowers, flsmidth, fly, foo, football, ford, forex, forsale, foundation, frl, frogans, fund, furniture, futbol, gal, gallery, garden, gbiz, gdn, gea, gent, ggee, gift, gifts, gives, giving, glass, gle, global, globo, gmail, gmo, gmx, goldpoint, golf, goo, goog, google, gop, got, graphics, gratis, green, gripe, group, gucci, guge, guide, guitars, guru, hamburg, hangout, haus, healthcare, help, here, hermes, hiphop, hitachi, hiv, holdings, holiday, homes, honda, horse, host, hosting, hotmail, house, how, hsbc, ibm, ice, ifm, iinet, immo, immobilien, industries, infiniti, ing, ink, institute, insure, international, investments, ipiranga, irish, ist, istanbul, itau, iwc, jaguar, java, jcb, jetzt, jlc, joburg, jot, joy, jprs, juegos, kaufen, kddi, kfh, kim, kinder, kitchen, kiwi, koeln, krd, kred, kyoto, lacaixa, land, landrover, lat, latrobe, lawyer, lds, lease, leclerc, legal, lgbt, liaison, lidl, life, lifestyle, lighting, like, limited, limo, lincoln, linde, link, live, loan, loans, london, lotte, lotto, ltd, ltda, lupin, luxe, luxury, madrid, maif, maison, man, management, mango, market, marketing, markets, marriott, media, meet, melbourne, meme, memorial, menu, meo, miami, microsoft, mini, mma, mobily, moda, moe, moi, monash, money, montblanc, mormon, mortgage, moscow, motorcycles, mov, movistar, mtn, mtpc, nadex, nagoya, navy, netbank, network, neustar, new, news, nexus, ngo, nhk, nico, ninja, nissan, norton, nowruz, nra, nrw, ntt, nyc, obi, okinawa, one, ong, onl, ooo, oracle, organic, osaka, otsuka, ovh, page, panerai, paris, pars, partners, parts, party, pharmacy, philips, photo, photography, photos, physio, piaget, pics, pictet, pictures, pin, pink, pizza, place, plumbing, pohl, poker, porn, praxi, press, prod, productions, prof, promo, properties, property, pub, qpon, quebec, racing, read, realtor, recipes, red, redstone, rehab, reise, reisen, reit, ren, rent, rentals, repair, report, republican, rest, restaurant, review, reviews, rich, ricoh, rio, rip, rocher, rocks, rodeo, room, rsvp, ruhr, ryukyu, saarland, safe, sakura, sale, salon, samsung, sandvik, sandvikcoromant, sanofi, sap, sapo, sarl, saxo, sbs, sca, scb, schmidt, scholarships, school, schule, schwarz, science, scor, scot, seat, seek, sener, services, sew, sex, sexy, sharp, shia, shiksha, shoes, shriram, singles, sky, skype, smile, social, software, sohu, solar, solutions, soy, space, spiegel, spreadbetting, stada, statoil, stc, stcgroup, stockholm, study, style, supplies, supply, support, surf, surgery, suzuki, swiss, sydney, symantec, systems, tab, taipei, tatar, tattoo, tax, tci, technology, telefonica, temasek, tennis, tienda, tips, tires, tirol, today, tokyo, tools, top, toray, toshiba, town, toys, trade, trading, training, trust, tui, tushu, ubs, university, uno, uol, vacations, vana, vegas, ventures, versicherung, vet, viajes, video, villas, virgin, vision, vista, vistaprint, viva, vlaanderen, vodka, vote, voting, voto, voyage, wales, walter, wang, wanggou, watch, webcam, website, wed, wedding, whoswho, wien, wiki, williamhill, win, windows, wme, work, works, world, wtc, wtf, xbox, xerox, xin, 佛山, 慈善, 集团, 在线, 八卦, موقع, 公益, 公司, 移动, 我爱你, москва, онлайн, сайт, 时尚, 淡马锡, орг, 삼성, 商标, 商店, 商城, дети, ポイント, 新闻, 中文网, 中信, 娱乐, 谷歌, 网店, संगठन, 餐厅, 网络, 飞利浦, 手机, ارامكو, بازار, موبايلي, همراه, 政府, شبكة, بيتك, 机构, 组织机构, 健康, рус, みんな, グーグル, 世界, 网址, 游戏, vermögensberater, vermögensberatung, 企业, 信息, 广东, 政务, xyz, yachts, yamaxun, yandex, yodobashi, yoga, yokohama, youtube, zara, zero, zip, zone, zuerich,

Some numbers

Invalid Domains according to the tld module: 818
Valid domains according to the tld module: 6269

@barseghyanartur

This comment has been minimized.

Copy link

@barseghyanartur barseghyanartur commented Feb 5, 2015

Hey, thanks!

I'll check it as soon as I get some free time.

Best regards,

Artur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment