Python program problem involving reading a web site.
Mike Varney
varney at collorado.edu
Thu May 30 22:42:48 EDT 2002
Hello.
I wrote a quick little program that is supposed to read the html from a web
site and to update the web counter to show another hit.
I am able to read the html code fine, but the counter on the web site is not
updating.
Here is the code.
Any suggestions?
Thanks.
import urllib # imports url library
from time import sleep # imports sleep timer
# Initilize variables
a = 0
t = 0
# User Input
x = input("How many hits do you want to add to counter? ")
t = input("How long do you want to pause between each hit? (Recommend > 1
min) ")
# while loop
while a < x:
# open and reads page
sock = urllib.geturl(http://foo.bar)
hampage = sock.read()
sock.close()
print a
sleep(t)
a = a+1
# print goodbye
print "you have increased the page count by "
print a
print "hits"
More information about the Python-list
mailing list