Spaces:
Runtime error
Runtime error
Commit ·
db192d0
1
Parent(s): e8e6dad
Update load_rock.py
Browse files- load_rock.py +23 -7
load_rock.py
CHANGED
|
@@ -2,7 +2,24 @@ from app_vars import *
|
|
| 2 |
from bs4 import BeautifulSoup as bs
|
| 3 |
import random as r
|
| 4 |
import requests
|
| 5 |
-
headers = {'User-Agent': 'Mozilla/5.0 (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
|
|
@@ -37,10 +54,9 @@ def get_rock_name_url():
|
|
| 37 |
url = url_of_rock(name)
|
| 38 |
path = f"{rs}/assets/img.{url.split('.')[-1]}"
|
| 39 |
print(path)
|
| 40 |
-
system(f'{curl_invoker} -A "Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion" {url}')
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
# url, _ = urlretrieve(url)
|
| 46 |
return name, path
|
|
|
|
| 2 |
from bs4 import BeautifulSoup as bs
|
| 3 |
import random as r
|
| 4 |
import requests
|
| 5 |
+
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',
|
| 6 |
+
"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",
|
| 7 |
+
"Accept-Encoding": "gzip, deflate, br",
|
| 8 |
+
"Accept-Language": "en-US,en;q=0.9",
|
| 9 |
+
"Cache-Control": "max-age=0",
|
| 10 |
+
"Cookie": """mindat=n5e0bck7vvnn6e0o9tkb49fs75; cf_clearance=PMEAfGmJF_UGxZYgB2jsRx5KsiZyNf2plDbXs4HoN5I-1703800389-0-2-d8c97f25.71e5db39.8fc820c5-0.2.1703800389""",
|
| 11 |
+
"Dnt": """1""",
|
| 12 |
+
"If-Modified-Since": """Sat, 17 Apr 2021 18:41:12 GMT""",
|
| 13 |
+
"If-None-Match": "607b2bc8-956c4",
|
| 14 |
+
"Prefer": "safe",
|
| 15 |
+
"Sec-Ch-Ua": r'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
|
| 16 |
+
"Sec-Ch-Ua-Mobile": "?0",
|
| 17 |
+
"Sec-Ch-Ua-Platform": '"Windows"',
|
| 18 |
+
"Sec-Fetch-Dest": "document",
|
| 19 |
+
"Sec-Fetch-Mode": "navigate",
|
| 20 |
+
"Sec-Fetch-Site": "none",
|
| 21 |
+
"Sec-Fetch-User": "?1",
|
| 22 |
+
"Upgrade-Insecure-Requests": "1",}
|
| 23 |
|
| 24 |
|
| 25 |
|
|
|
|
| 54 |
url = url_of_rock(name)
|
| 55 |
path = f"{rs}/assets/img.{url.split('.')[-1]}"
|
| 56 |
print(path)
|
| 57 |
+
# system(f'{curl_invoker} -A "Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion" {url}')
|
| 58 |
+
with open(path, "wb") as f:
|
| 59 |
+
img = requests.get(url,headers = headers).content
|
| 60 |
+
print(img)
|
| 61 |
+
f.write(img)
|
|
|
|
| 62 |
return name, path
|