Prepare headers consistently
This commit is contained in:
parent
8f9a165c2f
commit
c71ea7a795
@ -45,10 +45,8 @@ class FirecrawlApp:
|
|||||||
Exception: If the scrape request fails.
|
Exception: If the scrape request fails.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = {
|
headers = self._prepare_headers()
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': f'Bearer {self.api_key}'
|
|
||||||
}
|
|
||||||
# Prepare the base scrape parameters with the URL
|
# Prepare the base scrape parameters with the URL
|
||||||
scrape_params = {'url': url}
|
scrape_params = {'url': url}
|
||||||
|
|
||||||
@ -101,10 +99,7 @@ class FirecrawlApp:
|
|||||||
Raises:
|
Raises:
|
||||||
Exception: If the search request fails.
|
Exception: If the search request fails.
|
||||||
"""
|
"""
|
||||||
headers = {
|
headers = self._prepare_headers()
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': f'Bearer {self.api_key}'
|
|
||||||
}
|
|
||||||
json_data = {'query': query}
|
json_data = {'query': query}
|
||||||
if params:
|
if params:
|
||||||
json_data.update(params)
|
json_data.update(params)
|
||||||
@ -297,3 +292,4 @@ class FirecrawlApp:
|
|||||||
raise Exception(f'Failed to {action}. Status code: {response.status_code}. Error: {error_message}')
|
raise Exception(f'Failed to {action}. Status code: {response.status_code}. Error: {error_message}')
|
||||||
else:
|
else:
|
||||||
raise Exception(f'Unexpected error occurred while trying to {action}. Status code: {response.status_code}')
|
raise Exception(f'Unexpected error occurred while trying to {action}. Status code: {response.status_code}')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user