Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- analyze_document.py +4 -1
- analyze_documents.py +4 -1
analyze_document.py
CHANGED
|
@@ -79,7 +79,10 @@ def download_image(url, output_path='temp_image.jpg'):
|
|
| 79 |
return None
|
| 80 |
|
| 81 |
try:
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
response.raise_for_status()
|
| 84 |
image_data = response.content
|
| 85 |
|
|
|
|
| 79 |
return None
|
| 80 |
|
| 81 |
try:
|
| 82 |
+
headers = {
|
| 83 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
| 84 |
+
}
|
| 85 |
+
response = requests.get(url, headers=headers, timeout=30)
|
| 86 |
response.raise_for_status()
|
| 87 |
image_data = response.content
|
| 88 |
|
analyze_documents.py
CHANGED
|
@@ -35,7 +35,10 @@ def download_image(url, output_path=None):
|
|
| 35 |
|
| 36 |
try:
|
| 37 |
print(f"DOCUMENT Attempting to download from: {url}", file=sys.stderr)
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
response.raise_for_status()
|
| 40 |
image_data = response.content
|
| 41 |
|
|
|
|
| 35 |
|
| 36 |
try:
|
| 37 |
print(f"DOCUMENT Attempting to download from: {url}", file=sys.stderr)
|
| 38 |
+
headers = {
|
| 39 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
| 40 |
+
}
|
| 41 |
+
response = requests.get(url, headers=headers, timeout=30)
|
| 42 |
response.raise_for_status()
|
| 43 |
image_data = response.content
|
| 44 |
|