import pywikibot
site = pywikibot.Site('test', 'wikipedia')
import matplotlib
page = pywikibot.Page(site, u"Main_Page")
text = page.text
text
'{{SHORTDESC:starting page}}\n:\'\'See also: [[test2wiki:|test2.wikipedia.org]] and [[testwikidata:|test.wikidata.org]]\'\'\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 mediawiki.org (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 [https://github.com/wikimedia/operations-mediawiki-config/blob/master/wmf-config/InitialiseSettings.php 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 [http://beta.wmflabs.org/ 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. test.wikipedia.org 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=http://en.wikipedia.org|logo Wikipedia]]\n| \'\'\'[//en.wikipedia.org/ Wikipedia]\'\'\'<br />Free encyclopedia\n| align="center" | [[File:Wiktionary-logo.svg |35x35px|link=http://www.wiktionary.org|logo Wiktionary]]\n| \'\'\'[http://www.wiktionary.org/ Wiktionary]\'\'\'<br />Free dictionary and thesaurus\n| align="center" | [[File:Wikinews-logo.svg|35x35px|link=http://www.wikinews.org|logo Wikinews]]\n| \'\'\'[http://www.wikinews.org/ Wikinews]\'\'\'<br />Free-content news\n| align="center" | [[File:Wikiquote-logo.svg|35x35px|link=http://www.wikiquote.org|logo Wikiquote]]\n| \'\'\'[http://www.wikiquote.org/ Wikiquote]\'\'\'<br /> collection of quotations\n|-\n| align="center" | [[File:Wikibooks-logo.svg|35x35px|link=http://www.wikibooks.org|logo Wikibooks]]\n| \'\'\'[http://www.wikibooks.org/ Wikibooks]\'\'\'<br />Free textbooks and manuals\n| align="center" | [[File:Wikispecies-logo.svg|35x35px|link=http://species.wikimedia.org|logo Wikispecies]]\n| \'\'\'[http://species.wikimedia.org/ Wikispecies]\'\'\'<br />Free directory of species\n| align="center" | [[File:Wikisource-logo.svg|35x35px|link=http://wikisource.org|logo Wikisource]]\n| \'\'\'[http://wikisource.org/ Wikisource]\'\'\'<br />Free-content library\n| align="center" | [[File:MediaWiki-logo.svg|35x35px|link=http://mediawiki.org|logo MediaWiki]]\n| \'\'\'[http://mediawiki.org/ MediaWiki]\'\'\'<br />MediaWiki software\n|-\n| align="center" | [[File:Wikiversity-logo.svg|35x35px|link=http://www.wikiversity.org|logo Wikiversity]]\n| \'\'\'[http://www.wikiversity.org/ Wikiversity]\'\'\'<br />Free learning materials and activities\n| align="center" | [[File:Commons-logo.svg|35x35px|link=http://commons.wikimedia.org|logo Commons]]\n| \'\'\'[http://commons.wikimedia.org/ Commons]\'\'\'<br />Free shared media repository\n| align="center" | [[File:Wikimedia Community Logo.svg|35x35px|link=http://meta.wikimedia.org|logo Meta-Wiki]]\n| \'\'\'[http://meta.wikimedia.org/ Meta-Wiki]\'\'\'<br />Wikimedia project coordination\n| align="center" | [[File:Wikidata-logo.svg|35x35px|link=http://www.wikidata.org|logo Wikidata]]\n| \'\'\'[http://www.wikidata.org/ 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
fonti
0
non_fonti
0