Python Forum
Cannot download latest version of a file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Cannot download latest version of a file (/thread-26256.html)



Cannot download latest version of a file - TheTechRobo - Apr-25-2020

I have gone through over five or six Python requests and urllib tutorials, but none of them will download the latest version of a file.

Here is what happens:

It downloads the latest version of bglug.py successfully. Everything works like a charm.

The second time I try, it doesn't fetch the latest version of the file, but I know it fetches the file because I set it up to delete the file first (just for testing purposes) and when I check, the file is there.

And it still won't download the latest version until the next day or so!

Is this server-side caching? Does Python have a web cache that I have to clear?

My code is as follows:
import requests, os

os.remove("bglug.py")

url = "https://raw.githubusercontent.com/TheTechRobo/bglugwatch-cleanslate/master/bglug.py"

r = requests.get(url, stream = True)

with open("bglug.py", "wb") as Writefile:

    for chunk in r.iter_content(chunk_size = 1024):

        if chunk:

            Writefile.write(chunk)
Does anyone else have the same problem? Thanks!


RE: Cannot download latest version of a file - snippsat - Apr-25-2020

(Apr-25-2020, 12:55 PM)TheTechRobo Wrote: Does anyone else have the same problem? Thanks!
No same file every time as i would except for that code,and with a raw url file link to GitHub.


RE: Cannot download latest version of a file - TheTechRobo - Apr-27-2020

More details:
After I update bglug.py on GitHub. when I run the mechanism again, it fetches the file, but doesn't include the new commit

I know it isn't that raw.githubusercontent.com hasn't been updated, as even after I verify it in a browser that it changed it still doesn't work.


RE: Cannot download latest version of a file - TheTechRobo - May-20-2020

OK! So it turns out that raw.githubusercontent.com takes time to update, even though it doesn't seem like it. So I'm marking this as solved. Ciao!