I have some URLs of some java files located in GitHub. I want to pass the URL to a method, download the file and save it with a different unique name.
This is the code I wrote and it has the issue mentioned below the code snippet.
!pip install wget
import wget
from datetime import datetime
def download_file(url):
# Creating file name
now_time =datetime.now()
millisec = now_time.timestamp() * 10000
millisec = str(millisec).split('.')[0]
partial_name = url.split('/')[-1].split('.')[0]
file_name = partial_name + millisec + '.java'
# Download the file and save in colab location
wget.download(url, file_name)
return file_name
A sample URL I pass to this method is 'https://github.com/e32wong/CloCom/blob/master/CloneDigger.java'
The issue is, the downloaded java file's content appears as an HTML content full of tags. But, the original file on GitHub is a simple java file.
I want to save the file as it is. Any solution to this, please.
