diff --git a/e2e.py b/e2e.py index da193bd..ae9710d 100644 --- a/e2e.py +++ b/e2e.py @@ -26,6 +26,5 @@ def test_single_data(): def test_v2(): p = Pinterest() images_url = p.search(keyword, images_to_download) - print(p.errors) - assert len(images_url) == images_to_download + assert len(images_url) == images_to_download, p.errors p.download(url_list=images_url, number_of_workers=number_of_workers, output_folder=output_folder) diff --git a/pinscrape/v2.py b/pinscrape/v2.py index 9726b68..2135f8e 100644 --- a/pinscrape/v2.py +++ b/pinscrape/v2.py @@ -204,6 +204,12 @@ def search(self, query: str, page_size=26) -> list: logging.warning(f"Image search has failed!, {response.status_code}, {response.text}") self.errors.append(f"Image search has failed!, {response.status_code}, {response.text}") return [] + + msg = f"Response Headers: {response.headers}" + msg += f"Response Content-Type: {response.headers.get('Content-Type')}" + msg += f"Response: {response.text}" + msg += f"Status Code: {response.headers}" + try: json_data = response.json() results = json_data.get('resource_response', {}).get('data', {}).get('results', []) @@ -214,6 +220,7 @@ def search(self, query: str, page_size=26) -> list: return image_urls except requests.exceptions.JSONDecodeError as jde: self.errors.append(response.text) + self.errors.append(msg) return []