aashraychegu commited on
Commit
aed8175
·
1 Parent(s): a649397

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
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
- # url = "https://www.mindat.org/"
7
- 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'
8
- headers = {'User-Agent': user_agent,
9
- "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",
10
- "Accept-Encoding": "gzip, deflate, br",
11
- "Accept-Language": "en-US,en;q=0.9",
12
- "Cache-Control": "max-age=0",
13
- } | {"Cookie": """mindat=n5e0bck7vvnn6e0o9tkb49fs75; cf_clearance=PMEAfGmJF_UGxZYgB2jsRx5KsiZyNf2plDbXs4HoN5I-1703800389-0-2-d8c97f25.71e5db39.8fc820c5-0.2.1703800389""",
14
- "Dnt": """1""",
15
- "If-Modified-Since": """Sat, 17 Apr 2021 18:41:12 GMT""",
16
- "If-None-Match": "607b2bc8-956c4",
17
- "Prefer": "safe",
18
- "Sec-Ch-Ua": r'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
19
- "Sec-Ch-Ua-Mobile": "?0",
20
- "Sec-Ch-Ua-Platform": '"Windows"',
21
- "Sec-Fetch-Dest": "document",
22
- "Sec-Fetch-Mode": "navigate",
23
- "Sec-Fetch-Site": "none",
24
- "Sec-Fetch-User": "?1",
25
- "Upgrade-Insecure-Requests": "1",}
26
 
27
  def greet():
28
  print("in greet")
29
  session = requests.Session()
30
- print(session.get(url,headers = headers).content)
 
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")