takomattyy commited on
Commit
fd1f4fc
·
verified ·
1 Parent(s): 3f04313

Upload 2 files

Browse files
Files changed (2) hide show
  1. analyze_document.py +4 -1
  2. 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
- response = requests.get(url)
 
 
 
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
- response = requests.get(url, timeout=30) # Added timeout
 
 
 
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