Open koito19960406 opened 2 weeks ago
KVDownloader already has user agents and proxies. It might be due to other reasons.
def worker(row, output_dir, cropped):
url, panoid = row.url, row.id
user_agent = random.choice(self.user_agents)
proxy = random.choice(self.proxies)
image_name = f"{panoid}.png" # Use id for file name
image_path = output_dir / image_name
try:
response = requests.get(
url, headers=user_agent, proxies=proxy, timeout=10
)
if response.status_code == 200:
with open(image_path, "wb") as f:
f.write(response.content)
if cropped:
img = Image.open(image_path)
w, h = img.size
img_cropped = img.crop((0, 0, w, h // 2))
img_cropped.save(image_path)
else:
if self.logger is not None:
self.logger.log_failed_pids(panoid)
except Exception as e:
if self.logger is not None:
self.logger.log_failed_pids(panoid)
print(f"Error: {e}")
I get the following error after downloading a few hundred images:
Using proxies and user agents might solve this issue.