1

I'm trying to read information from a given web page but urllib.urlopen.read() does not pick up on any changes made within the last couple of hours of when urllib.urlopen.read() is ran.

Heres my code:

import urllib2

url_latest = ('http://panoptic-fearless.ldc.yougov.net/questionnaires/Test_maj_demo_newG4_2/versions/')

versions = urllib2.urlopen(url_latest)

print versions.info()['date']

html = versions.read()

print html

This prints everything on the page which is fine. But if something is recently changed than this script fails to show it.

I can see the latest information from this web page if I manually insert this url in chrome:

http://panoptic-fearless.ldc.yougov.net/questionnaires/Test_maj_demo_newG4_2/versions/ 

Any idea whats going on? How can I access the latest up to date version of the web page?

Apologies if I've got some of my terms wrong Im still faily new to the programming world.

SOLVED.

The info was being cache'd somewhere. I had to add this line to revalidate its cache entry each time the script is called:

versions.add_header('Cache-Control', 'max-age=0')

Boosted_d16
  • 13,340
  • 35
  • 98
  • 158

0 Answers0