Skip to content

Commit

Permalink
fix: removed new api from test on github action because github action…
Browse files Browse the repository at this point in the history
… changin headers before call that makes API calling to be failed
  • Loading branch information
iamatulsingh committed Oct 28, 2024
1 parent bb19ff3 commit e0dec56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Run test suite
run: |
pytest -sv e2e.py
pytest -sv e2e.py -k "test_single_data"
10 changes: 2 additions & 8 deletions pinscrape/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ 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', [])
Expand All @@ -218,8 +212,8 @@ def search(self, query: str, page_size=26) -> list:
self.client_context = json_data['client_context']
logging.info(f"Total {len(image_urls)} image(s) found.")
return image_urls
except requests.exceptions.JSONDecodeError:
self.errors.append(msg)
except requests.exceptions.JSONDecodeError as jde:
self.errors.append(jde.args)
return []


Expand Down

0 comments on commit e0dec56

Please sign in to comment.