Spaces:
Runtime error
Runtime error
Commit ·
aed8175
1
Parent(s): a649397
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,31 +3,30 @@ import os
|
|
| 3 |
import requests
|
| 4 |
|
| 5 |
url = "https://www.mindat.org/imagecache/46/9c/03220450016186848702713.jpg"
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
| 18 |
-
"Sec-Ch-Ua":
|
| 19 |
-
"Sec-
|
| 20 |
-
"Sec-
|
| 21 |
-
"Sec-Fetch-
|
| 22 |
-
"Sec-Fetch-
|
| 23 |
-
"
|
| 24 |
-
"Sec-Fetch-User": "?1",
|
| 25 |
-
"Upgrade-Insecure-Requests": "1",}
|
| 26 |
|
| 27 |
def greet():
|
| 28 |
print("in greet")
|
| 29 |
session = requests.Session()
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
with gr.Blocks() as iface:
|
| 33 |
btn = gr.Button("Run")
|
|
|
|
| 3 |
import requests
|
| 4 |
|
| 5 |
url = "https://www.mindat.org/imagecache/46/9c/03220450016186848702713.jpg"
|
| 6 |
+
headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
|
| 7 |
+
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
| 8 |
+
"Accept-Encoding": "gzip, deflate, br",
|
| 9 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 10 |
+
"Cache-Control": "max-age=0",
|
| 11 |
+
"Cookie": """mindat=n5e0bck7vvnn6e0o9tkb49fs75; cf_clearance=PMEAfGmJF_UGxZYgB2jsRx5KsiZyNf2plDbXs4HoN5I-1703800389-0-2-d8c97f25.71e5db39.8fc820c5-0.2.1703800389""",
|
| 12 |
+
"Dnt": """1""",
|
| 13 |
+
"If-Modified-Since": """Sat, 17 Apr 2021 18:41:12 GMT""",
|
| 14 |
+
"If-None-Match": "607b2bc8-956c4",
|
| 15 |
+
"Prefer": "safe",
|
| 16 |
+
"Sec-Ch-Ua": r'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
|
| 17 |
+
"Sec-Ch-Ua-Mobile": "?0",
|
| 18 |
+
"Sec-Ch-Ua-Platform": '"Windows"',
|
| 19 |
+
"Sec-Fetch-Dest": "document",
|
| 20 |
+
"Sec-Fetch-Mode": "navigate",
|
| 21 |
+
"Sec-Fetch-Site": "none",
|
| 22 |
+
"Sec-Fetch-User": "?1",
|
| 23 |
+
"Upgrade-Insecure-Requests": "1",}
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def greet():
|
| 26 |
print("in greet")
|
| 27 |
session = requests.Session()
|
| 28 |
+
with open("./img.jpg","wb+") as f:
|
| 29 |
+
f.write(session.get(url,headers = headers).content)
|
| 30 |
|
| 31 |
with gr.Blocks() as iface:
|
| 32 |
btn = gr.Button("Run")
|