Rosetta Code/Count examples: Difference between revisions
→{{header|Python}}: Update to Python 3; correct URLs; include User-Agent that won't result in a 403 from the API.
(Changed code to use "xmltree" and "xmlparser" as DOM modules are no longer provided. Changed the old URL by the right one.) |
(→{{header|Python}}: Update to Python 3; correct URLs; include User-Agent that won't result in a 403 from the API.) |
||
Line 2,193:
=={{header|Python}}==
<lang python>
import xml.dom.minidom
r = Request(
headers={'User-Agent': 'Mozilla/5.0'})
x = urlopen(r)
tasks = []
for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName(
t = i.getAttribute('title').replace(
headers={'User-Agent': 'Mozilla/5.0'})
tasks.append( y.read().lower().count("{{header|") )▼
y = urlopen(r)
print t.replace("_", " ") + ": %d examples." % tasks[-1]▼
print
</lang>
=={{header|R}}==
|