{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "f1976c16-cfc7-4d2d-8c7e-71d72dba78b6", "metadata": { "tags": [] }, "outputs": [], "source": [ "import requests\n", "import os\n", "import json" ] }, { "cell_type": "code", "execution_count": 3, "id": "a90dde3c-c536-4828-95cc-dbe1bbedd39d", "metadata": { "tags": [] }, "outputs": [], "source": [ "api_endpoint = os.getenv('API_ENDPOINT')\n", "api_key = os.getenv('API_KEY')" ] }, { "cell_type": "code", "execution_count": 4, "id": "5e08f601-f431-4ba2-97c3-eee6ba769682", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "200\n" ] }, { "data": { "text/plain": [ "{'urls': ['https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445',\n", " 'https://www.thehindu.com/news/national/tmc-dharna-derek-obrien-saket-gokhale-others-continue-dharna-at-delhis-mandir-marg-police-station/article68046304.ece',\n", " 'https://www.livemint.com/news/india/arvind-kejriwal-will-move-supreme-court-sc-against-delhi-hcs-order-in-excise-policy-case-sources-11712660787632.html',\n", " 'https://www.moneycontrol.com/news/technicals/technical-view-nifty39s-record-rally-continues-crosses-22750-for-first-time-resistance-at-22740-22770_17520591.html',\n", " '1'],\n", " 'scraped_texts': [\"The U.S. tech firm will announce the plans soon when Japanese Prime Minister Fumio Kishida visits the United States, the Nikkei said in its interview with Microsoft President Brad Smith.\\nMicrosoft Corp will invest about $2.9 billion over the next two years to boost its artificial intelligence (AI) business in Japan, the Nikkei newspaper reported on Tuesday citing the company president.\\nThe U.S. tech firm will announce the plans soon when Japanese Prime Minister Fumio Kishida visits the United States, the Nikkei said in its interview with Microsoft President Brad Smith.\\nUnder the plan, which the Nikkei said would be Microsoft's largest investment in Japan, the company will install advanced AI semiconductors at two existing facilities in eastern and western Japan, the report said. The company also plans to announce an AI-related reskilling program in Japan to train 3 million workers over three years, and to set up a new lab in Tokyo for research and development on robotics and AI, the report said.\\nCentral Bank Fixed Deposit: How much will you earn by investing Rs 1 lakh, 3 lakh and 5 lakh at 8.05% interest rate?\\nBy accepting cookies, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.\",\n", " 'Trinamool Congress (TMC) leaders who were detained by Delhi Police while staging a dharna outside the Election Commission\\'s office continued their protest at Mandir Marg police station on April 9.\\nAAP leaders, including Saurabh Bharadwaj, met the protesting TMC leaders who camped overnight at the police station.\\nThe TMC leaders had met the full bench of the EC on Monday, demanding that the heads of the Enforcement Directorate, Central Bureau of Investigation, National Investigation Agency and Income Tax department be changed as they were allegedly acting at the behest of the ruling BJP.\\nThe TMC leaders later announced they were sitting on a 24-hour dharna outside the EC office. The delegation comprised Rajya Sabha MP Derek O\\'Brien, Mohammed Nadimul Haque, Dola Sen, Saket Gokhale, Sagarika Ghose, MLA Vivek Gupta, former MPs Arpita Ghosh, Santanu Sen and Abir Ranjan Biswas and TMC West Bengal students\\' wing vice-president Sudip Raha. The leaders were later detained by Delhi Police and forcefully evicted from the site.\\nPolice said they released the TMC leaders on Monday night. However, the leaders stayed put at the police station through the night and continued their dharna.\\nIn a post on X on Tuesday, Mr. Gokhale said the party leaders were continuing their protest at the police station.\\nWhile all TMC leaders sat inside the police station premises, Mr. Haque and Mr. Ghose, who had gone out briefly, were not allowed to re-enter. They sat on a dharna outside the boundary of the police station.\\nAsked about the police statement that the TMC leaders were released from detention on Monday evening, Haque said, \"We had announced a 24-hour dharna. They did not allow us to sit in front of the EC and brought us here. So, we are sitting here,\" he said.\\nThe Mamata Banerjee-led TMC has been alleging that the central probe agencies have been targeting opposition parties ahead of the Lok Sabha polls at the behest of the BJP-led central government.',\n", " 'Delhi Chief Minister Arvind Kejriwal will move the Supreme Court against Delhi High Court\\'s order in excise policy case.\\nThe Aam Aadmi Party announced on Tuesday that Delhi Chief Minister Arvind Kejriwal \"will approach the Supreme Court against the Delhi High Court\\'s order\" rejecting his plea challenging his arrest and remand by the Enforcement Directorate in the excise policy case.\\nAam Aadmi Party leader Saurabh Bharadwaj stated that the party has full faith in the Supreme Court. “We believe it will grant relief to CM Kejriwal, as it did to Sanjay Singh,\" he added. \"We disagree with the Delhi High Court\\'s order,\" he said. AAP MP Sanjay Singh was arrested in connection with the same liquor case and was recently granted bail by the Supreme Court.\\nMeanwhile, sources in the AAP told news agency ANI that the party doe not agree with the Delhi High Court\\'s decision. “The Aam Aadmi Party does not agree with the decision of the Delhi High Court. Kejriwal will go to the Supreme Court against HC\\'s decision. Kejriwal can go to the Supreme Court tomorrow itself.\"\\nEarlier, the Delhi High Court dismissed CM Arvind Kejriwal\\'s plea, calling his arrest and remand by the Enforcement Directorate \"valid\". The bench of Justice Swarna Kanta Sharma said the ED was in possession of enough material, which led them to arrest Kejriwal.\\nReacting to the order, Delhi BJP president Virendraa Sachdeva said, \"...If leaders of the Aam Aadmi Party have some ethics left, then they should apologise to the people of Delhi...If they (AAP) are questioning the court\\'s decision now then it is an insult...\"\\nKejriwal was arrested by the the Enforcement Directorate on March 21 in relation to the excise policy case. Later, a trial court sent Arvind Kejriwal to judicial custody till April 15, 2024.\\nThe Enforcement Directorate alleged that the AAP is the major beneficiary of the proceeds of crime generated in the alleged liquor scam. The agency also claimed that Kejriwal was directly involved in the formation of the excise policy.\\nThe case pertains to alleged irregularities and money laundering in framing and implementing the Delhi Excise Policy 2022, which was later scrapped. Former Delhi minister Manish Sisodia and BRS leader K Kavitha are currently lodged in jail in connection with the same case.\\nUnlock a world of Benefits! From insightful newsletters to real-time stock tracking, breaking news and a personalized newsfeed – it\\'s all here, just a click away! Login Now!\\nCatch all the Business News, Market News, Events and Updates on Live Mint. Download The to get Daily Market Updates.',\n", " 'Nifty Bank index opened 200 points higher and extended the gains as the day progress and inched closer to 49,000 mark.\\nOn the auspicious day of Gudi Padwa on April 9 , the Indian market climbed to fresh record high with the Nifty50 index crossing 22,750 for the first time with support from positive global cues.\\nThe index continued the previous session rally and touched fresh record high of 22,768.40 in the opening session and remained positive in the first half. However, selling in the second half erased all the gains to close the session with minor losses.\\nNifty ended 24.50 points, or 0.11 percent, lower at 22,641.80, from the previous close and formed a bearish candle on the daily chart.\\nDiscover the latest business news, Sensex, and Nifty updates. Obtain Personal Finance insights, tax queries, and expert opinions on Moneycontrol or download the Moneycontrol App to stay updated!\\nCopyright © e-Eighteen.com Ltd. All rights reserved. Reproduction of news articles, photos, videos or any other content in whole or in part in any form or medium without express writtern permission of moneycontrol.com is prohibited.',\n", " ''],\n", " 'scrape_errors': ['',\n", " '',\n", " '',\n", " '',\n", " 'Message: Malformed URL: URL constructor: 1 is not a valid URL.'],\n", " 'summaries': ['Microsoft Corp will invest about $2.9 billion over the next two years to boost its artificial intelligence (AI) business in Japan, the Nikkei newspaper reports. The company also plans to announce an AI-related reskilling program in Japan to train 3 million workers over three years.',\n", " 'A delegation of AAP leaders has met the top bench of the Indian Election Commission (EC) in Delhi.',\n", " 'Aam Aadmi Party leader: \"We believe it will grant relief to CM Kejriwal\" Delhi High Court dismissed Kejriwal\\'s plea challenging arrest and remand by Enforcement Directorate. Kejriwal can go to the Supreme Court tomorrow itself.',\n", " 'The Nifty50 index opened 200 points higher and extended the gains as the day progress. The index crossed 22,750 for the first time with support from positive global cues. Selling in the second half erased all the gains to close the session with minor losses.',\n", " ''],\n", " 'summarizer_error': ''}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Valid payload\n", "payload = \\\n", "{\n", " \"urls\": [\n", " \"https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445\",\n", " \"https://www.thehindu.com/news/national/tmc-dharna-derek-obrien-saket-gokhale-others-continue-dharna-at-delhis-mandir-marg-police-station/article68046304.ece\",\n", " \"https://www.livemint.com/news/india/arvind-kejriwal-will-move-supreme-court-sc-against-delhi-hcs-order-in-excise-policy-case-sources-11712660787632.html\",\n", " \"https://www.moneycontrol.com/news/technicals/technical-view-nifty39s-record-rally-continues-crosses-22750-for-first-time-resistance-at-22740-22770_17520591.html\",\n", " \"1\"\n", " ],\n", " \"key\": api_key\n", "}\n", "\n", "r = requests.post(api_endpoint, json=payload)\n", "\n", "print(r.status_code)\n", "r.json()" ] }, { "cell_type": "code", "execution_count": 5, "id": "3c9586df-8980-469e-9277-3d5e929eef43", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "500\n" ] }, { "data": { "text/plain": [ "{'urls': [],\n", " 'scraped_texts': [],\n", " 'scrape_errors': [],\n", " 'summaries': '',\n", " 'summarizer_error': 'error: list index out of range'}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Empty payload\n", "payload = \\\n", "{\n", " \"urls\": [],\n", " \"key\": api_key\n", "}\n", "\n", "r = requests.post(api_endpoint, json=payload)\n", "\n", "print(r.status_code)\n", "r.json()" ] }, { "cell_type": "code", "execution_count": 6, "id": "a754e677-4dd1-477f-bbc9-f543a63b8394", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "422\n" ] }, { "data": { "text/plain": [ "{'detail': [{'type': 'list_type',\n", " 'loc': ['body', 'urls'],\n", " 'msg': 'Input should be a valid list',\n", " 'input': 'https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445',\n", " 'url': 'https://errors.pydantic.dev/2.6/v/list_type'}]}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Invalid payload\n", "payload = \\\n", "{\n", " \"urls\": \"https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445\",\n", " \"key\": api_key\n", "}\n", "\n", "r = requests.post(api_endpoint, json=payload)\n", "\n", "print(r.status_code)\n", "r.json()" ] }, { "cell_type": "code", "execution_count": 7, "id": "184356e3-bd51-4540-9c21-ee8b4d4f95b2", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "401\n" ] }, { "data": { "text/plain": [ "{'urls': ['https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445',\n", " 'https://www.thehindu.com/news/national/tmc-dharna-derek-obrien-saket-gokhale-others-continue-dharna-at-delhis-mandir-marg-police-station/article68046304.ece',\n", " 'https://www.livemint.com/news/india/arvind-kejriwal-will-move-supreme-court-sc-against-delhi-hcs-order-in-excise-policy-case-sources-11712660787632.html',\n", " 'https://www.moneycontrol.com/news/technicals/technical-view-nifty39s-record-rally-continues-crosses-22750-for-first-time-resistance-at-22740-22770_17520591.html',\n", " '1'],\n", " 'scraped_texts': '',\n", " 'scrape_errors': '',\n", " 'summaries': '',\n", " 'summarizer_error': 'error: Authentication error: Invalid API key.'}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Invalid key\n", "payload = \\\n", "{\n", " \"urls\": [\n", " \"https://www.zeebiz.com/technology/news-microsoft-to-invest-29-billion-to-boost-ai-business-in-japan-nikkei-283445\",\n", " \"https://www.thehindu.com/news/national/tmc-dharna-derek-obrien-saket-gokhale-others-continue-dharna-at-delhis-mandir-marg-police-station/article68046304.ece\",\n", " \"https://www.livemint.com/news/india/arvind-kejriwal-will-move-supreme-court-sc-against-delhi-hcs-order-in-excise-policy-case-sources-11712660787632.html\",\n", " \"https://www.moneycontrol.com/news/technicals/technical-view-nifty39s-record-rally-continues-crosses-22750-for-first-time-resistance-at-22740-22770_17520591.html\",\n", " \"1\"\n", " ],\n", " \"key\": \"api_key\"\n", "}\n", "\n", "r = requests.post(api_endpoint, json=payload)\n", "\n", "print(r.status_code)\n", "r.json()" ] }, { "cell_type": "code", "execution_count": null, "id": "94916ebe-a75b-446e-affd-9d139841cc08", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }