import pywikibot
site = pywikibot.Site('test', 'wikipedia')
import matplotlib
page = pywikibot.Page(site, u"Main_Page")
text = page.text
'{{SHORTDESC:starting page}}\n:\'\'See also: [[test2wiki:|]] and [[testwikidata:|]]\'\'\n__NOEDITSECTION____NOTOC__\nThis is a \'\'\'test wiki\'\'\' that runs on [[mw:|the MediaWiki software]]. Ordinarily it runs the same version of the code as (plus other wikis in "[[wikitech:Deployments/One_week|group 0]]"), but may be configured differently with experimental features. The contents of this site may be volatile and buggy.\n\n<div id="mp-tfa" >\nThe [[Special:Version|current version]] of MediaWiki running on this wiki is {{CURRENTVERSION}}. See [[Wikipedia:Configuration|Wikipedia:Configuration]] and [[wikitech:testwiki|wikitech:testwiki]] and [ InitialiseSettings.php] for information about the configuration of this wiki.\n\n{{TNT|Wikipedia:What we do on this wiki}}\n\n\'\'\'Please note:\'\'\' there is a new test cluster created as a replacement for prototype.wikimedia available [ here]. It is a clone of all production wikis, where developers and regular users can test new features before we deploy them to production wiki. In case you want to test gadgets or user scripts on any Wikimedia project, you can also use that site. is not for testing of unreviewed software or MediaWiki, it is a last place where software is deployed before it goes to live production. New software, extensions and gadgets can be deployed immediately to the deployment cluster.\n</div>\n\n== Please read before contributing here ==\n\n{{TNT|Wikipedia:What Test Wiki is not}}\n\n{{TNT|Wikipedia:Administrators}}\n{{Wikipedia:Bureaucrats}}\n\n== Wikimedia Projects ==\n\n<div class="plainlinks" id="mf-spr" title="Sister Projects">\n{| class="plainlinks" style="background-color: transparent; text-align: left; width: 100%;"\n| align="center" | [[File:Wikipedia-logo-v2.svg|35x35px|link=|logo Wikipedia]]\n| \'\'\'[// Wikipedia]\'\'\'<br />Free encyclopedia\n| align="center" | [[File:Wiktionary-logo.svg |35x35px|link=|logo Wiktionary]]\n| \'\'\'[ Wiktionary]\'\'\'<br />Free dictionary and thesaurus\n| align="center" | [[File:Wikinews-logo.svg|35x35px|link=|logo Wikinews]]\n| \'\'\'[ Wikinews]\'\'\'<br />Free-content news\n| align="center" | [[File:Wikiquote-logo.svg|35x35px|link=|logo Wikiquote]]\n| \'\'\'[ Wikiquote]\'\'\'<br /> collection of quotations\n|-\n| align="center" | [[File:Wikibooks-logo.svg|35x35px|link=|logo Wikibooks]]\n| \'\'\'[ Wikibooks]\'\'\'<br />Free textbooks and manuals\n| align="center" | [[File:Wikispecies-logo.svg|35x35px|link=|logo Wikispecies]]\n| \'\'\'[ Wikispecies]\'\'\'<br />Free directory of species\n| align="center" | [[File:Wikisource-logo.svg|35x35px|link=|logo Wikisource]]\n| \'\'\'[ Wikisource]\'\'\'<br />Free-content library\n| align="center" | [[File:MediaWiki-logo.svg|35x35px|link=|logo MediaWiki]]\n| \'\'\'[ MediaWiki]\'\'\'<br />MediaWiki software\n|-\n| align="center" | [[File:Wikiversity-logo.svg|35x35px|link=|logo Wikiversity]]\n| \'\'\'[ Wikiversity]\'\'\'<br />Free learning materials and activities\n| align="center" | [[File:Commons-logo.svg|35x35px|link=|logo Commons]]\n| \'\'\'[ Commons]\'\'\'<br />Free shared media repository\n| align="center" | [[File:Wikimedia Community Logo.svg|35x35px|link=|logo Meta-Wiki]]\n| \'\'\'[ Meta-Wiki]\'\'\'<br />Wikimedia project coordination\n| align="center" | [[File:Wikidata-logo.svg|35x35px|link=|logo Wikidata]]\n| \'\'\'[ Wikidata]\'\'\'<br />Free knowledge base\n|}</div>'
fonti = 0
non_fonti = 0
for x in text:
    if "<ref" in x:
        fonti += 1
    if "{{F" in x:
        non_fonti += 1
    if "{{senza fonte" in x:
        non_fonti += 1