with open('pydata.txt', 'w') as f:
    for i in range(1, 21):
        tempurl = url.format(i)
print('Val : {}\n\n'.format(tempurl))
f.write(urlopen(tempurl).read())
Perl beats Python in fetching HTML pages?