(20250211) Slight changes in NSE's IPO section.
This commit is contained in:
@@ -105,7 +105,7 @@ class NSECurrentIPO(AsyncNSEBase):
|
||||
|
||||
# Pass on the initialization to the parent:
|
||||
super().__init__(
|
||||
base_url = r"https://www.nseindia.com/market-data/all-upcoming-issues-ipo",
|
||||
base_url = r"https://www.nseindia.com/",
|
||||
data_url = r"https://www.nseindia.com/api/ipo-current-issue",
|
||||
http_client = http_client,
|
||||
cookies_refresh_interval = cookies_refresh_interval,
|
||||
|
||||
@@ -106,7 +106,7 @@ class NSEUpcomingIPO(AsyncNSEBase):
|
||||
|
||||
# Pass on the initialization to the parent:
|
||||
super().__init__(
|
||||
base_url = r"https://www.nseindia.com/market-data/all-upcoming-issues-ipo",
|
||||
base_url = r"https://www.nseindia.com/",
|
||||
data_url = r"https://www.nseindia.com/api/all-upcoming-issues?category=ipo",
|
||||
http_client = http_client,
|
||||
cookies_refresh_interval = cookies_refresh_interval,
|
||||
@@ -218,7 +218,7 @@ class NSEUpcomingIPO(AsyncNSEBase):
|
||||
formatted_data = []
|
||||
for ipo in raw_json:
|
||||
issue_size = regex.find_first(text = str(ipo.get("issueSize")), pattern = r"[\d,]+\.?[\d,]*")
|
||||
upper_band, lower_band = self.get_band_prices(ipo.get("priceRange"))
|
||||
upper_band, lower_band = self.get_band_prices(ipo.get("issuePrice"))
|
||||
formatted_data.append(NSEIPO(
|
||||
scrapeTs = timestamp,
|
||||
symbol = ipo["symbol"],
|
||||
|
||||
@@ -190,6 +190,9 @@ class AsyncREST:
|
||||
api_response.httpCode = response.status_code
|
||||
api_response.message = response.reason_phrase
|
||||
|
||||
# Assume success if the response's HTTP code is in the 200 series:
|
||||
api_response.success = response.is_success
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
api_response.exception = exception
|
||||
@@ -244,6 +247,9 @@ class AsyncREST:
|
||||
api_response.httpCode = response.status_code
|
||||
api_response.message = response.reason_phrase
|
||||
|
||||
# Assume success if the response's HTTP code is in the 200 series:
|
||||
api_response.success = response.is_success
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
api_response.exception = exception
|
||||
@@ -295,6 +301,66 @@ class AsyncREST:
|
||||
api_response.httpCode = response.status_code
|
||||
api_response.message = response.reason_phrase
|
||||
|
||||
# Assume success if the response's HTTP code is in the 200 series:
|
||||
api_response.success = response.is_success
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
api_response.exception = exception
|
||||
api_response.message = str(exception)
|
||||
self._printer(exception, api_response.url, api_response.method, headers, json, data)
|
||||
|
||||
# Done here:
|
||||
return api_response
|
||||
|
||||
async def patch(
|
||||
self,
|
||||
url: str,
|
||||
headers: dict = None,
|
||||
json: dict = None,
|
||||
data: dict = None,
|
||||
content: str | bytes = None,
|
||||
auth: httpx.Auth = None
|
||||
) -> ApiResponse:
|
||||
|
||||
"""
|
||||
To call an API using the PATCH method.
|
||||
:param url: The URL to call.
|
||||
:param headers: The headers to pass.
|
||||
:param json: The params to send in the JSON body.
|
||||
:param data: The params to send in the form-data in the body.
|
||||
:param content: The raw content to be sent in the body (typically as an octet-stream).
|
||||
:param auth: Any authentication credentials that need to be sent.
|
||||
:return: A structured response that includes the raw response, the exception (if any), and so on.
|
||||
"""
|
||||
|
||||
# Prepare the structure of the response:
|
||||
api_response = ApiResponse(
|
||||
action = inspect.stack()[1].function,
|
||||
url = url,
|
||||
method = "POST"
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
# Make the API call:
|
||||
response = await self._http_client.patch(
|
||||
url = url,
|
||||
headers = headers,
|
||||
json = json,
|
||||
data = data,
|
||||
content = content,
|
||||
auth = auth
|
||||
)
|
||||
|
||||
# Note down the results:
|
||||
api_response.response = response
|
||||
api_response.httpCode = response.status_code
|
||||
api_response.message = response.reason_phrase
|
||||
|
||||
# Assume success if the response's HTTP code is in the 200 series:
|
||||
api_response.success = response.is_success
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
api_response.exception = exception
|
||||
@@ -340,6 +406,9 @@ class AsyncREST:
|
||||
api_response.httpCode = response.status_code
|
||||
api_response.message = response.reason_phrase
|
||||
|
||||
# Assume success if the response's HTTP code is in the 200 series:
|
||||
api_response.success = response.is_success
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
api_response.exception = exception
|
||||
|
||||
Reference in New Issue
Block a user