File size: 522 Bytes
171f55b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import requests

headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
}

def read_from_url(file_path):
    if file_path.startswith("http"):
        tmp_path = f'/tmp/clamd_{file_path.split("/")[-1].split("?")[0]}'
        print("tmp_path ", tmp_path)
        resp = requests.get(file_path, headers=headers).content
        with open(tmp_path, "wb") as f:
            f.write(resp)
        return tmp_path
    return file_path