0

Im working with url lib2 and I need a help. When I get the information I need from the website, it works fine, but if the info on the website changed, the result still the same, Im thinking that I have to find a way of cleaning up the "cache" or the "lib.close" ... I don't know... Could someone help me out with that please? Thank you

Here is the code:

import urllib2            

url = 'http://website.com'

response = urllib2.urlopen(url)
webContent = response.read()

string = webContent.find('***')
alert = webContent[string+11:]

webContent = alert
string = webContent.find('***')
alert = webContent[:string]
alert = alert.replace('</strong>',' ')

print alert
Ren
  • 2,852
  • 2
  • 23
  • 45

1 Answers1

0

urllib2 does not do caching. Either a HTTP Proxy is involved or the caching happens server-side.

Check the response headers. X-Cache or X-Cache-Lookup would mean that you are connected through a proxy.

dron22
  • 1,235
  • 10
  • 20
  • Thank you for the answer, I looked into X-Cache and X-Cache-lookup and I could find the solution for me... If I change the information on the website and refresh it on my computer browser, it updates immediately... Any more information you could share with me? – Thiago Neves Apr 09 '16 at 18:55
  • Can you add more information/code about your project in your question? It's you who host the website, right? What tech stack do you use? This [user](http://stackoverflow.com/a/10008270/6079540) had to spoof his useragent...And by the way you could simplify your code by using a rgx: `import re; alert = re.findall(r'\*{3}(.+)\*{3}', webContent)[0]` – dron22 Apr 09 '16 at 22:00