Python (programming language)/GetURL.py: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric M Gearhart
(Going to put an example Python script here)
imported>Eric M Gearhart
No edit summary
Line 1: Line 1:
{{subpages}}
{{subpages}}
<pre>
import urllib2                     
cnt=0
for line in urllib2.urlopen('http://en.citizendium.org/wiki/Main_Page'):
    cnt += line.count('<img src')
print cnt
</pre>


You can try this from home! Paste this script into a file (such as getimg.py) and if you have installed a Python interpreter (on Mac or Linux you're all set already, Windows you will have to install Python) you can run this script.
You can try this from home! Paste this script into a file (such as getimg.py) and if you have installed a Python interpreter (on Mac or Linux you're all set already, Windows you will have to install Python) you can run this script.

Revision as of 22:44, 28 June 2009

This article is developing and not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
 
Template:GetURL.py header
import urllib2                      
cnt=0
for line in urllib2.urlopen('http://en.citizendium.org/wiki/Main_Page'):
    cnt += line.count('<img src')
print cnt

You can try this from home! Paste this script into a file (such as getimg.py) and if you have installed a Python interpreter (on Mac or Linux you're all set already, Windows you will have to install Python) you can run this script.