{"id":46784,"date":"2024-08-02T09:51:28","date_gmt":"2024-08-02T09:51:28","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=46784"},"modified":"2024-08-02T09:52:47","modified_gmt":"2024-08-02T09:52:47","slug":"how-to-send-a-post-request-with-python","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-send-a-post-request-with-python\/","title":{"rendered":"How to Send a POST Request with Python"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p>Most tutorials focus on GET requests, but working with an API frequently requires using POST requests as well. Web servers don\u2019t randomly send data; a request must be made to the server to retrieve data before it responds with data.<\/p>\n\n\n\n<p>In this article, we will explore how to use the requests library to make a <strong>POST request<\/strong> with headers and a body. We will cover the fundamental concepts of headers and request bodies, demonstrate their usage in the <strong>requests.post() <\/strong>method, and build two real-life projects <a href=\"https:\/\/www.scraperapi.com\/?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\">using <\/a><a href=\"https:\/\/www.scraperapi.com\/?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\"><strong>ScraperAPI<\/strong><\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Sending a Python POST Request<\/strong><\/h2>\n\n\n\n<p>To quickly send a POST request in Python:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Import the <a href=\"https:\/\/pypi.org\/project\/requests\/\" target=\"_blank\" rel=\"noopener\">\u2018requests\u2019<\/a> library.<\/li>\n\n\n\n<li>Define the URL<\/li>\n\n\n\n<li>Prepare Your Data<\/li>\n\n\n\n<li>Send the POST request using \u2018<strong>requests.post()\u2019<\/strong>.<\/li>\n\n\n\n<li>Handle the response.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> requests\n\nurl = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\ndata = {\n    <span class=\"hljs-string\">\"Id\"<\/span>: <span class=\"hljs-number\">001<\/span>,\n    <span class=\"hljs-string\">\"Customer\"<\/span>: <span class=\"hljs-string\">\"Donald Biden\"<\/span>,\n}\n\nresponse = requests.post(url, json=data)\nprint(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here is how to send a POST request with the ScraperAPI Async API:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\n\ndef create_async_request():\n    r = requests.post(\n        url=<span class=\"hljs-string\">'https:\/\/async.scraperapi.com\/jobs'<\/span>,\n        json={\n            <span class=\"hljs-string\">'apiKey'<\/span>: Your_API_Key,\n            <span class=\"hljs-string\">'url'<\/span>: <span class=\"hljs-string\">'https:\/\/crypto.com\/price'<\/span>  <span class=\"hljs-comment\"># Target URL<\/span>\n        }\n    )\n    <span class=\"hljs-keyword\">print<\/span>(r.text)  <span class=\"hljs-comment\"># Response includes the job ID and status URL<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>To get the most out of this article, you must have <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">Python<\/a> installed on your computer along with the <a href=\"https:\/\/pypi.org\/project\/requests\/\" target=\"_blank\" rel=\"noopener\"><strong>\u2018requests\u2019<\/strong><\/a> library. You can install requests using pip by running this command in your terminal:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">pip install requests<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>If you manage your project dependencies with <a href=\"https:\/\/pipenv.pypa.io\/\" target=\"_blank\" rel=\"noopener\">Pipenv<\/a>, use this command:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">pipenv install requests<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Once installation is complete, you can import and use requests in your Python scripts like this:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> requests<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Using Requests \u201cpost()\u201d Method<\/strong><\/h2>\n\n\n\n<p>The <a href=\"https:\/\/pypi.org\/project\/requests\/\" target=\"_blank\" rel=\"noopener\"><strong>requests<\/strong><\/a> library provides a simple and intuitive way to interact with web APIs. The <strong>post() <\/strong>method is specifically designed for sending POST requests.<\/p>\n\n\n\n<p>To send a POST request using the Requests Library, call the <strong>requests.post()<\/strong> method and pass the target URL as the first argument and then pass the data you want to submit to the server with the \u201c<strong>data\u201d <\/strong>argument. Let&#8217;s explore different ways to do this:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a><strong>Sending a Basic POST Request<\/strong><\/h3>\n\n\n\n<p>The simplest form of a POST request can be sent by just passing the URL to the `<strong>post()<\/strong>` method of the `<strong>requests<\/strong>` library. We will be using <a href=\"http:\/\/httpbin.org\" target=\"_blank\" rel=\"noopener\">httpbin.org <\/a>as our target URL for this tutorial.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> requests\n\nurl = <span class=\"hljs-string\">'http:\/\/httpbin.org\/post'<\/span>\nresponse = requests.post(url)\nprint(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Setting the POST Data<\/strong><\/h3>\n\n\n\n<p>While our previous example demonstrated a basic POST request, let&#8217;s now explore how to send data along with it. Sending data in JSON format is a common practice when interacting with APIs.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\nimport json\n\nurl = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\n\n<span class=\"hljs-comment\"># Define the JSON data you want to send in the POST request<\/span>\ndata = {\n    <span class=\"hljs-string\">\"Id\"<\/span>: <span class=\"hljs-number\">100252<\/span>,\n    <span class=\"hljs-string\">\"Customer\"<\/span>: <span class=\"hljs-string\">\"Donald Biden\"<\/span>,\n    <span class=\"hljs-string\">\"Quantity\"<\/span>: <span class=\"hljs-number\">1<\/span>,\n    <span class=\"hljs-string\">\"Price\"<\/span>: <span class=\"hljs-number\">2024.00<\/span>\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Convert the data dictionary to a JSON string<\/span>\njson_data = json.dumps(data)\nresponse = requests.post(url, data=json_data)\n\n<span class=\"hljs-keyword\">print<\/span>(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here, we create a dictionary \u201c<strong>data\u201d<\/strong> containing the key-value pairs that we want to send . Then, we convert this dictionary to JSON format using the <strong>json.dumps() <\/strong>function. If no <strong>Content-Type <\/strong>header is passed to the <strong>requests.post()<\/strong> method, the \u201c<strong>application\/x-www-form-urlencoded\u201d<\/strong> content type will be used instead. Remember to import the <strong>json<\/strong> module to handle JSON objects in your script.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a><strong>Sending a POST Request with JSON Data<\/strong><\/h3>\n\n\n\n<p>If you think our JSON example looks a bit complex, you&#8217;re absolutely right. Fortunately, the <strong>requests<\/strong> library makes it even easier to handle JSON data. Instead of manually converting your dictionary into a JSON string and setting headers, you can simply use the <strong>json<\/strong> argument directly with your data. The <strong>requests<\/strong> library will handle the headers and encoding for you.<\/p>\n\n\n\n<p>Here&#8217;s a more straightforward way to send JSON data:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> requests\n\nurl = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\ndata = {\n    <span class=\"hljs-string\">\"Id\"<\/span>: <span class=\"hljs-number\">100252<\/span>,\n    <span class=\"hljs-string\">\"Customer\"<\/span>: <span class=\"hljs-string\">\"Donald Biden\"<\/span>,\n    <span class=\"hljs-string\">\"Quantity\"<\/span>: <span class=\"hljs-number\">1<\/span>,\n    <span class=\"hljs-string\">\"Price\"<\/span>: <span class=\"hljs-number\">2024.00<\/span>\n}\n\nresponse = requests.post(url, json=data)\nprint(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Understanding the Response<\/strong><\/h4>\n\n\n\n<p>As before, we print the server&#8217;s response to examine the results.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"465\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-1024x465.png\" alt=\"\" class=\"wp-image-46786\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-1024x465.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-300x136.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-768x349.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-1536x697.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-1-2048x930.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>When you send a POST request to httpbin.org\/post, the server responds by echoing back information about the request. This typically includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>data<\/strong>: The JSON data you sent in the request, which you can verify against the data dictionary you created.<\/li>\n\n\n\n<li><strong>User-Agent<\/strong>: Details about the tool used to send the request, which in this case is the Python requests library.<\/li>\n\n\n\n<li><strong>Content-Type<\/strong>: This specifies the data type in the body of the POST message.<\/li>\n<\/ul>\n\n\n\n<p>By examining the response content, you can verify if your POST request was successful and if the data was received correctly by the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a><\/a><strong>POST Method\u2019s Syntax and Parameters<\/strong><\/h2>\n\n\n\n<p>The <strong>requests.post() <\/strong>method in Python&#8217;s requests library is versatile and allows for a wide range of configurations to customize your POST requests. Let&#8217;s break down its syntax and explore the various parameters it accepts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a><strong>Syntax<\/strong><\/h3>\n\n\n\n<p>The <strong>requests.post()<\/strong> method has the following syntax:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">requests.post(url, data={key: value}, json={key: value}, **kwargs)<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Basic Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>url (Required)<\/strong>: This is the URL to which the POST request is sent.<\/li>\n\n\n\n<li><strong>data<\/strong>: This parameter is used to send data in the body of the POST request. It can accept various data formats, such as dictionaries, lists of tuples, bytes, or file-like objects. The specific format depends on the requirements of the API or server you&#8217;re interacting with.<\/li>\n\n\n\n<li><strong>json<\/strong>: A Python object that will be serialized to JSON format and sent in the request body. This is a convenient alternative to using the <strong>data<\/strong> parameter with JSON data.<\/li>\n\n\n\n<li><strong>**kwargs<\/strong>: These are additional keyword arguments to provide further customization:<\/li>\n<\/ul>\n\n\n\n<p>Example<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">url = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\njson_object = {<span class=\"hljs-string\">\"key\"<\/span>: <span class=\"hljs-string\">\"value\"<\/span>}\nresponse = requests.post(url, data=json_object, timeout=<span class=\"hljs-number\">2.00<\/span>)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Arguments<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><strong>headers<\/strong><\/h4>\n\n\n\n<p>The <strong>headers<\/strong> argument allows you to specify HTTP headers to include in the request. This is used to&nbsp; provide additional information to the server, such as the content type or authentication details or modify the default headers.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">headers = {<span class=\"hljs-string\">\"Content-Type\"<\/span>: <span class=\"hljs-string\">\"application\/json\"<\/span>}\nresponse = requests.post(url, data=json_data, headers=headers)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>If no \u201c<strong>Content-Type\u201d<\/strong> header is provided, <strong>requests<\/strong> defaults to \u201c<strong>application\/x-www-form-urlencoded<\/strong>\u201d.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><strong>cookies<\/strong><\/h4>\n\n\n\n<p>Cookies can be sent with a POST request to manage sessions or store \u201cuser-specific\u201d data on the client-side. This can be a dictionary or a <strong>CookieJar<\/strong> object.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">cookies = {<span class=\"hljs-string\">\"favcolor\"<\/span>: <span class=\"hljs-string\">\"Blue\"<\/span>}\nresponse = requests.post(url, data=json_data, cookies=cookies)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>allow_redirects<\/strong><\/h4>\n\n\n\n<p>The allow_redirects argument controls whether redirects should be followed. By default, redirects are followed. If you want to disable this behavior, set <strong>allow_redirects<\/strong> to <strong>False<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">response = requests.post(url, data=json_data, allow_redirects=<span class=\"hljs-keyword\">False<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>proxies<\/strong><\/h4>\n\n\n\n<p>If you need to <a href=\"https:\/\/www.devopsschool.com\/blog\/understanding-residential-socks5-proxies-benefits-limitations-and-how-they-compare-to-other-proxy-types\/\">route your request through a proxy<\/a>, you can use the <strong>proxies<\/strong> argument.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">proxies = {<span class=\"hljs-string\">\"http\"<\/span>: <span class=\"hljs-string\">\"http:\/\/Your_proxy_IP_Address:Your_proxy_port\"<\/span>, <span class=\"hljs-string\">\"https\"<\/span>: <span class=\"hljs-string\">\"https:\/\/Your_proxy_IP_Address_2:Your_proxy_port_2\"<\/span>}\n\nresponse = requests.post(url, data=json_data, proxies=proxies)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><strong>stream<\/strong><\/h4>\n\n\n\n<p>Typically, <strong>requests<\/strong> downloads the entire response content before making it available to your script. Setting <strong>stream<\/strong> to <strong>True<\/strong> allows you to process the response data as it arrives in <strong>chunks<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">response = requests.post(url, data=json_data, stream=<span class=\"hljs-keyword\">True<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><strong>timeout<\/strong><\/h4>\n\n\n\n<p>The <strong>timeout<\/strong> parameter specifies a time limit for the request in seconds, after which requests will raise a timeout exception if no response is received.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">response = requests.post(url, data=json_data, timeout=2.00)<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>files<\/strong><\/h4>\n\n\n\n<p>The <strong>files<\/strong> argument allows you to upload files with your POST request. It expects a dictionary where keys are the field names for the files, and values are file-like objects opened in binary mode. This is commonly used for sending images, documents, or any other type of file data to a server.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\n\nurl = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\nmyfiles = {<span class=\"hljs-string\">'file'<\/span>: open(<span class=\"hljs-string\">'cute_pup.png'<\/span> ,<span class=\"hljs-string\">'rb'<\/span>)}  <span class=\"hljs-comment\"># Open the file in binary mode<\/span>\n\nresponse = requests.post(url, files = myfiles)\n\n<span class=\"hljs-keyword\">print<\/span>(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>These are just a few of the commonly used arguments. The requests library offers extensive customization options, making it suitable for diverse scenarios and API interactions. For more detailed information on the \u2018<strong>requests\u2019<\/strong> library, refer to the <a href=\"https:\/\/docs.python-requests.org\/en\/latest\/\" target=\"_blank\" rel=\"noopener\">official documentation<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a><strong>Using POST Requests With Sessions<\/strong><\/h3>\n\n\n\n<p>When working with web services or APIs, especially those that require authentication or maintain state across requests, using sessions can significantly simplify your code and improve performance. <strong>requests<\/strong> provides a <strong>Session<\/strong> object that allows you to persist certain parameters across requests. This is useful for sending multiple POST requests to the same server, as it can automatically handle cookies and other state information.<\/p>\n\n\n\n<p>Here&#8217;s an example of how to use a session to send POST requests with JSON data:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\n\nurl = <span class=\"hljs-string\">\"http:\/\/httpbin.org\/post\"<\/span>\n\n<span class=\"hljs-comment\"># Define the JSON data you want to send in the POST request<\/span>\ndata = {\n    <span class=\"hljs-string\">\"Id\"<\/span>: <span class=\"hljs-number\">100252<\/span>,\n    <span class=\"hljs-string\">\"Customer\"<\/span>: <span class=\"hljs-string\">\"Donald Biden\"<\/span>,\n    <span class=\"hljs-string\">\"Quantity\"<\/span>: <span class=\"hljs-number\">1<\/span>,\n    <span class=\"hljs-string\">\"Price\"<\/span>: <span class=\"hljs-number\">2024.00<\/span>\n}\n\ndata_two = {\n    <span class=\"hljs-string\">\"Id\"<\/span>: <span class=\"hljs-number\">100253<\/span>,\n    <span class=\"hljs-string\">\"Customer\"<\/span>: <span class=\"hljs-string\">\"Thomas John\"<\/span>,\n    <span class=\"hljs-string\">\"Quantity\"<\/span>: <span class=\"hljs-number\">3<\/span>,\n    <span class=\"hljs-string\">\"Price\"<\/span>: <span class=\"hljs-number\">1994.99<\/span>\n}\n\n<span class=\"hljs-comment\"># Create a session object<\/span>\nsession = requests.Session()\n\n<span class=\"hljs-comment\"># Set the Content-Type header to application\/json for all requests in the session<\/span>\nsession.headers.update({<span class=\"hljs-string\">'Content-Type'<\/span>: <span class=\"hljs-string\">'application\/json'<\/span>})\n\n<span class=\"hljs-comment\"># Send the POST request with JSON data using the session object<\/span>\nresponse_one = session.post(url, json=data)\n\n<span class=\"hljs-comment\"># You can send another POST request using the same session<\/span>\nresponse_two = session.post(url, json=data_two)\n\n<span class=\"hljs-comment\"># Close the session<\/span>\nsession.close()\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Here, we create a Session object using requests.Session(). This session object allows us to persist certain parameters, such as headers, across multiple requests. Then, we update the session&#8217;s headers to include <strong>&#8216;Content-Type&#8217;: &#8216;application\/json<\/strong>&#8216;, ensuring that all requests sent through this session will have this header.<\/p>\n\n\n\n<p>Next, we use the <strong>session.post()<\/strong> method to send our POST request with the JSON data. This method works similarly to <strong>requests.post(),<\/strong> but it uses the session&#8217;s parameters. We can send multiple requests using the same session, and the session will handle cookies and other stateful information automatically.<\/p>\n\n\n\n<p>Finally, we close the session using <strong>session.close() <\/strong>to free up resources.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a><\/a><strong>Using ScraperAPI\u2019s async scraper with POST requests<\/strong><\/h2>\n\n\n\n<p>For larger scraping projects, dealing with complexities like dynamic content, IP blocking, and browser management can become overwhelming. <a href=\"https:\/\/www.scraperapi.com\/?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\">ScraperAPI is a tool designed to handle these challenges<\/a> for you. It provides an API that allows you to scrape websites without worrying about infrastructure or anti-scraping measures, saving you time and effort.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"553\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2.png\" alt=\"\" class=\"wp-image-46787\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2.png 991w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2-300x167.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2-768x429.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2-740x414.png 740w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-2-355x199.png 355w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/figure>\n\n\n\n<p>Using <a href=\"https:\/\/www.scraperapi.com\/\" target=\"_blank\" rel=\"noopener\">ScraperAPI<\/a> is straightforward. Just send the URL you would like to scrape to the API along with your API key and our API will return the HTML response from the URL you want to scrape.<\/p>\n\n\n\n<p>To get started, <a href=\"https:\/\/www.scraperapi.com\/signup?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\">create an account on ScraperAPI<\/a> and obtain your API key. You can start with a free trial that includes <strong>5,000 free API credits.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a><\/a><strong>Sending a POST Request to Crypto.com Using ScraperAPI&#8217;s Async Requests Method<\/strong><\/h3>\n\n\n\n<p>One of ScraperAPI&#8217;s latest features is its async scraping functionality, which is ideal for handling websites that might have slower response times or when you need to scrape many URLs concurrently.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"902\" height=\"558\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-3.png\" alt=\"\" class=\"wp-image-46788\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-3.png 902w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-3-300x186.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-3-768x475.png 768w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s explore how to use ScraperAPI&#8217;s async requests method with POST requests to retrieve cryptocurrency prices from <a href=\"http:\/\/crypto.com\/price\" target=\"_blank\" rel=\"noopener\">crypto.com<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><strong>Submitting an Asynchronous Scraping Job<\/strong><\/h4>\n\n\n\n<p>To submit an async job, you send a POST request to the ScraperAPI endpoint with your API key and the target URL. This request triggers a job, and the response includes a unique <strong>statusUrl<\/strong> that you can use to check the job&#8217;s progress.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\n\ndef create_async_request():\n    r = requests.post(\n        url=<span class=\"hljs-string\">'https:\/\/async.scraperapi.com\/jobs'<\/span>,\n        json={\n            <span class=\"hljs-string\">'apiKey'<\/span>: Your_API_Key,\n            <span class=\"hljs-string\">'url'<\/span>: <span class=\"hljs-string\">'https:\/\/crypto.com\/price'<\/span>  <span class=\"hljs-comment\"># Target URL<\/span>\n        }\n    )\n    <span class=\"hljs-keyword\">print<\/span>(r.text)  <span class=\"hljs-comment\"># Response includes the job ID and status URL<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>Note: Remember to replace <strong>Your_API_Key<\/strong> with your <strong>ScraperAPI API key<\/strong>.<\/em><\/p>\n\n\n\n<p>Upon execution, you should receive a response with an <strong>id<\/strong> (the job identifier), a <strong>statusUrl<\/strong> (where you can check the job status), and other details. Your response should be similar to this:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json\">{<span class=\"hljs-attr\">\"id\"<\/span>:<span class=\"hljs-string\">\"373442c0-2ddd-4549-ad67-e8df20d9eab2\"<\/span>,<span class=\"hljs-attr\">\"attempts\"<\/span>:<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-attr\">\"status\"<\/span>:<span class=\"hljs-string\">\"running\"<\/span>,<span class=\"hljs-attr\">\"statusUrl\"<\/span>:<span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/jobs\/373442c0-2ddd-4549-ad67-e8df20d9eab2\"<\/span>,<span class=\"hljs-attr\">\"url\"<\/span>:<span class=\"hljs-string\">\"https:\/\/crypto.com\/price\"<\/span>,<span class=\"hljs-attr\">\"supposedToRunAt\"<\/span>:<span class=\"hljs-string\">\"2024-04-25T18:43:02.228Z\"<\/span>}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>This response indicates that the job has been created and is currently running.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><strong>Check the Status of an Async Job<\/strong><\/h4>\n\n\n\n<p>To check the status of the async job, use the <strong>statusUrl<\/strong> provided in the response:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> requests\n\ndef check_async_response(statusUrl):\n    response = requests.get(url=statusUrl)\n    print(response.text)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>By running this code, you can track the job&#8217;s progress. Initially, the status might be &#8220;<strong>running<\/strong>&#8220;, but once completed, it changes to &#8220;<strong>finished<\/strong>&#8220;, with the response containing the scraped data.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a><\/a><strong>Retrieving Results<\/strong><\/h4>\n\n\n\n<p>When the job status is &#8220;<strong>finished<\/strong>&#8220;, the response key in the output will contain the scraped content. You need&nbsp; to retrieve the results within 4 hours, as the response data is stored for a limited time before being deleted.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">{\n    <span class=\"hljs-string\">\"id\"<\/span>: <span class=\"hljs-string\">\"6cf7e34f-9575-4578-b736-5fc4c10642c1\"<\/span>,\n    <span class=\"hljs-string\">\"attempts\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n    <span class=\"hljs-string\">\"status\"<\/span>: <span class=\"hljs-string\">\"finished\"<\/span>,\n    <span class=\"hljs-string\">\"statusUrl\"<\/span>: <span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/jobs\/6cf7e34f-9575-4578-b736-5fc4c10642c1\"<\/span>,\n    <span class=\"hljs-string\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/crypto.com\/price\"<\/span>,\n    <span class=\"hljs-string\">\"response\"<\/span>: {\n        <span class=\"hljs-string\">\"headers\"<\/span>: {\n            <span class=\"hljs-string\">\"date\"<\/span>: <span class=\"hljs-string\">\"Thu, 25 Apr 2024 18:30:41 GMT\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\n<span class=\"hljs-string\">\"content-type\"<\/span>: <span class=\"hljs-string\">\"text\/html; charset=utf-8\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"content-length\"<\/span>: <span class=\"hljs-string\">\"580450\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"connection\"<\/span>: <span class=\"hljs-string\">\"keep-alive\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"x-powered-by\"<\/span>: <span class=\"hljs-string\">\"Express\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"access-control-allow-origin\"<\/span>: <span class=\"hljs-string\">\"undefined\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"access-control-allow-headers\"<\/span>: <span class=\"hljs-string\">\"Origin, X-Requested-With, Content-Type,\nAccept\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"access-control-allow-methods\"<\/span>: <span class=\"hljs-string\">\"HEAD,GET,POST,DELETE,OPTIONS,PUT\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"access-control-allow-credentials\"<\/span>: <span class=\"hljs-string\">\"true\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"x-robots-tag\"<\/span>: <span class=\"hljs-string\">\"none\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"set-cookie\"<\/span>: &#91;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"__cf_bm=de1cLy7ovqKrsve2oAPm3ON8hd_40aBlpp4xfJGZGng-1714069840-1.0.1.1-e0Gy5Dj2AcQbjycbep5_U3AFaYJkA_vnEDFwFseHorJzYXcewZOA4zBoJrjeCzMnMETJL3c.rNR1YgLxkUJcgA;\npath=\/; expires=Thu, 25-Apr-24 19:00:40 GMT; domain=.crypto.com; HttpOnly;\nSecure; SameSite=None\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"_cfuvid=MEhpvpk8UxL0qYf6f2wA2LX233JqXen2tXcEt3IRVic-1714069840990-0.0.1.1-604800000;\npath=\/; domain=.crypto.com; HttpOnly; Secure; SameSite=None\"<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ],\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"sa-final-url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/crypto.com\/price\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"sa-statuscode\"<\/span>: <span class=\"hljs-string\">\"200\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"sa-credit-cost\"<\/span>: <span class=\"hljs-string\">\"1\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"sa-proxy-hash\"<\/span>: <span class=\"hljs-string\">\"undefined\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"etag\"<\/span>: <span class=\"hljs-string\">\"W\/\\\"8db62-YXxX1TgxjdwlH9trc7gaXNiPuT4\\\"\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"vary\"<\/span>: <span class=\"hljs-string\">\"Accept-Encoding\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"strict-transport-security\"<\/span>: <span class=\"hljs-string\">\"max-age=15724800; includeSubDomains\"<\/span>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 },\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"body\"<\/span>: <span class=\"hljs-string\">\"Response HTML here\"<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"statusCode\"<\/span>: <span class=\"hljs-number\">200<\/span>,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span class=\"hljs-string\">\"credits\"<\/span>: <span class=\"hljs-number\">1<\/span>\n\u00a0\u00a0\u00a0 }\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Scraping Amazon Data with ScraperAPI&#8217;s Async Scraper<\/strong><\/h2>\n\n\n\n<p>ScraperAPI offers specialized tools for <a href=\"https:\/\/www.devopsschool.com\/blog\/what-is-website-scraping-complete-guide\/\">scraping data from popular platforms<\/a> like Amazon. Our &#8220;<a href=\"https:\/\/www.scraperapi.com\/solutions\/ecommerce-data-collection\/amazon-scraper\/?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\"><strong>Amazon Search API (Async)<\/strong><\/a>&#8221; provides a structured way to retrieve product information based on search terms, and it&#8217;s useful for larger-scale data extraction tasks. Let&#8217;s explore how to utilize this API to scrape Amazon product search data.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"681\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-4.png\" alt=\"\" class=\"wp-image-46789\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-4.png 934w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-4-300x219.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/image-4-768x560.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/figure>\n\n\n\n<p>To begin, we import the <strong>requests<\/strong> library. Then we define a<strong> main() <\/strong>function that will contain our code. Since we&#8217;ll be sending data in JSON format, we set the<strong> Content-Type<\/strong> header to <strong>application\/jso<\/strong>n. This ensures that the server understands the format of the data we&#8217;re sending.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import requests\n\ndef main():\n    url = <span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/structured\/amazon\/search\"<\/span>\n    headers = {\n        <span class=\"hljs-string\">\"Content-Type\"<\/span>: <span class=\"hljs-string\">\"application\/json\"<\/span>\n    }\n    data = {\n        <span class=\"hljs-string\">\"apiKey\"<\/span>: <span class=\"hljs-string\">\"Your_API_Key\"<\/span>,\n        <span class=\"hljs-string\">\"query\"<\/span>: <span class=\"hljs-string\">\"iPhone 15\"<\/span>,\n        <span class=\"hljs-string\">\"ref\"<\/span>: <span class=\"hljs-string\">\"olp_f_usedAcceptable\"<\/span>,\n        <span class=\"hljs-string\">\"s\"<\/span>: <span class=\"hljs-string\">\"price-desc-rank\"<\/span>,\n        <span class=\"hljs-string\">\"tld\"<\/span>: <span class=\"hljs-string\">\"com\"<\/span>,\n        <span class=\"hljs-string\">\"callback\"<\/span>: {\n  <span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"webhook\"<\/span>,\n            <span class=\"hljs-string\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/\"<\/span>  <span class=\"hljs-comment\"># Replace with your callback URL<\/span>\n        }\n    }\n    response = requests.post(url, json=data, headers=headers)\n    <span class=\"hljs-keyword\">print<\/span>(response.text)\n\nmain()\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><em>Note: Remember to replace <strong>Your_API_Key<\/strong> with your <strong>ScraperAPI API key<\/strong>.<\/em><\/p>\n\n\n\n<p>Here, we provide the parameters that define our Amazon search:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>apiKey<\/strong>: This is where you replace &#8220;<strong>Your_API_Key<\/strong>&#8221; with your actual ScraperAPI API key, which authenticates your access to the Async Scraper.<\/li>\n\n\n\n<li><strong>query<\/strong>: This is the search term you want to use on Amazon, for example, &#8220;<strong>iPhone 15<\/strong>&#8221; to retrieve results related to the iPhone 15.<\/li>\n\n\n\n<li><strong>ref<\/strong>: A reference string used by Amazon, such as &#8220;<strong>olp_f_usedAcceptable<\/strong>&#8220;.<\/li>\n\n\n\n<li><strong>s<\/strong>: This parameter controls the sorting of the search results. For instance, &#8220;<strong>price-desc-rank<\/strong>&#8221; sorts the results by price in descending order.<\/li>\n\n\n\n<li><strong>tld:<\/strong> This specifies the top-level domain of the Amazon website you want to search, such as &#8220;<strong>com<\/strong>&#8221; for amazon.com or &#8220;<strong>co.uk<\/strong>&#8221; for amazon.co.uk.<\/li>\n<\/ul>\n\n\n\n<p>With our parameters set, we send a POST request to the API endpoint using the<strong> requests.post()<\/strong> method, including the specified headers and JSON data. ScraperAPI will then process our request and respond with information about the submitted job, including a unique job ID and a <strong>statusUrl.<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json\">{<span class=\"hljs-attr\">\"id\"<\/span>:<span class=\"hljs-string\">\"bfa2f6ca-e76a-4fcc-a7ae-da8beaa4040d\"<\/span>,<span class=\"hljs-attr\">\"attempts\"<\/span>:<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-attr\">\"status\"<\/span>:<span class=\"hljs-string\">\"running\"<\/span>,<span class=\"hljs-attr\">\"statusUrl\"<\/span>:<span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/jobs\/bfa2f6ca-e76a-4fcc-a7ae-da8beaa4040d\"<\/span>,<span class=\"hljs-attr\">\"query\"<\/span>:<span class=\"hljs-string\">\"iPhone 15\"<\/span>,<span class=\"hljs-attr\">\"ref\"<\/span>:<span class=\"hljs-string\">\"olp_f_usedAcceptable\"<\/span>,<span class=\"hljs-attr\">\"s\"<\/span>:<span class=\"hljs-string\">\"price-desc-rank\"<\/span>,<span class=\"hljs-attr\">\"tld\"<\/span>:<span class=\"hljs-string\">\"com\"<\/span>,<span class=\"hljs-attr\">\"supposedToRunAt\"<\/span>:<span class=\"hljs-string\">\"2024-04-25T19:05:07.026Z\"<\/span>}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>To check the status of our scraping job and retrieve the results, we define a function called <strong>check_status()<\/strong>. This function takes the <strong>statusUrl<\/strong> obtained from the initial response as its argument. Using <strong>requests.get()<\/strong>, we send a GET request to the <strong>statusUrl<\/strong>, allowing us to determine whether the job is still running or has completed.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">def check_status(statusUrl):\n    r = requests.get(url = statusUrl)\n    <span class=\"hljs-keyword\">print<\/span>(r.text)\ncheck_status(<span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/jobs\/bfa2f6ca-e76a-4fcc-a7ae-da8beaa4040d\"<\/span>)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Once the job is finished, the response from the <strong>statusUrl<\/strong> will contain the extracted product data under the response key in the JSON object. The final response will include the structured data extracted from Amazon, formatted in JSON, making it easy to parse and utilize for further analysis or integration into your applications.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json\">{\n    <span class=\"hljs-attr\">\"id\"<\/span>: <span class=\"hljs-string\">\"bfa2f6ca-e76a-4fcc-a7ae-da8beaa4040d\"<\/span>,\n    <span class=\"hljs-attr\">\"attempts\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n    <span class=\"hljs-attr\">\"status\"<\/span>: <span class=\"hljs-string\">\"finished\"<\/span>,\n    <span class=\"hljs-attr\">\"statusUrl\"<\/span>: <span class=\"hljs-string\">\"https:\/\/async.scraperapi.com\/jobs\/bfa2f6ca-e76a-4fcc-a7ae-da8beaa4040d\"<\/span>,\n    <span class=\"hljs-attr\">\"query\"<\/span>: <span class=\"hljs-string\">\"iPhone 15\"<\/span>,\n    <span class=\"hljs-attr\">\"ref\"<\/span>: <span class=\"hljs-string\">\"olp_f_usedAcceptable\"<\/span>,\n    <span class=\"hljs-attr\">\"s\"<\/span>: <span class=\"hljs-string\">\"price-desc-rank\"<\/span>,\n    <span class=\"hljs-attr\">\"tld\"<\/span>: <span class=\"hljs-string\">\"com\"<\/span>,\n    <span class=\"hljs-attr\">\"response\"<\/span>: {\n        <span class=\"hljs-attr\">\"headers\"<\/span>: {\n            <span class=\"hljs-attr\">\"date\"<\/span>: <span class=\"hljs-string\">\"Thu, 25 Apr 2024 19:05:11 GMT\"<\/span>,\n            <span class=\"hljs-attr\">\"content-type\"<\/span>: <span class=\"hljs-string\">\"application\/json; charset=utf-8\"<\/span>,\n            <span class=\"hljs-attr\">\"content-length\"<\/span>: <span class=\"hljs-string\">\"26593\"<\/span>,\n            <span class=\"hljs-attr\">\"connection\"<\/span>: <span class=\"hljs-string\">\"keep-alive\"<\/span>,\n            <span class=\"hljs-attr\">\"x-powered-by\"<\/span>: <span class=\"hljs-string\">\"Express\"<\/span>,\n            <span class=\"hljs-attr\">\"access-control-allow-origin\"<\/span>: <span class=\"hljs-string\">\"undefined\"<\/span>,\n            <span class=\"hljs-attr\">\"access-control-allow-headers\"<\/span>: <span class=\"hljs-string\">\"Origin, X-Requested-With, Content-Type, Accept\"<\/span>,\n            <span class=\"hljs-attr\">\"access-control-allow-methods\"<\/span>: <span class=\"hljs-string\">\"HEAD,GET,POST,DELETE,OPTIONS,PUT\"<\/span>,\n            <span class=\"hljs-attr\">\"access-control-allow-credentials\"<\/span>: <span class=\"hljs-string\">\"true\"<\/span>,\n            <span class=\"hljs-attr\">\"x-robots-tag\"<\/span>: <span class=\"hljs-string\">\"none\"<\/span>,\n            <span class=\"hljs-attr\">\"set-cookie\"<\/span>: &#91;\n                <span class=\"hljs-string\">\"sp-cdn=delete; Domain=.amazon.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=\/; Secure; HttpOnly\"<\/span>\n            ],\n            <span class=\"hljs-attr\">\"sa-final-url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/s?k=iPhone%2015&amp;ref=olp_f_usedAcceptable&amp;s=price-desc-rank\"<\/span>,\n            <span class=\"hljs-attr\">\"sa-statuscode\"<\/span>: <span class=\"hljs-string\">\"200\"<\/span>,\n            <span class=\"hljs-attr\">\"sa-credit-cost\"<\/span>: <span class=\"hljs-string\">\"5\"<\/span>,\n            <span class=\"hljs-attr\">\"sa-proxy-hash\"<\/span>: <span class=\"hljs-string\">\"undefined\"<\/span>,\n<span class=\"hljs-attr\">\"etag\"<\/span>: <span class=\"hljs-string\">\"W\/\\\"67e1-qw7jH5r29IrlzNOWtgrJyQt30i8\\\"\"<\/span>,\n            <span class=\"hljs-attr\">\"vary\"<\/span>: <span class=\"hljs-string\">\"Accept-Encoding\"<\/span>,\n            <span class=\"hljs-attr\">\"strict-transport-security\"<\/span>: <span class=\"hljs-string\">\"max-age=15724800; includeSubDomains\"<\/span>\n        },\n        <span class=\"hljs-attr\">\"body\"<\/span>: {\n            <span class=\"hljs-attr\">\"ads\"<\/span>: &#91;\n                {\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Boost Infinite iPhone 15 Pro Max (256 GB) \\u2014 Natural Titanium &#91;Locked]. Requires unlimited plan starting at $60\/mo.\"<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBQTL9Z\"<\/span>,\n                    <span class=\"hljs-attr\">\"brand\"<\/span>: <span class=\"hljs-string\">\"iPhone on Boost Infinte\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81YQTED1r5L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.4<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/aax-us-iad.amazon.com\/x\/c\/RC98KFmWsAEdxduP9dXJQTYAAAGPFqW3UAEAAAH2AQBvbm9fdHhuX2JpZDcgICBvbm9fdHhuX2ltcDEgICDgnjxr\/https:\/\/www.amazon.com\/gp\/aw\/d\/B0CHBQTL9Z\/?_encoding=UTF8&amp;pd_rd_plhdr=t&amp;aaxitk=d3d8785e02cd16d1c54fa1ccc21b7282&amp;hsa_cr_id=0&amp;qid=1714071910&amp;sr=1-1-9e67e56a-6f64-441f-a281-df67fc737124&amp;ref_=sbx_be_s_sparkle_lsi4d_asin_0_bkgd&amp;pd_rd_w=2pU4D&amp;content-id=amzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b%3Aamzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_p=417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;pd_rd_wg=72Qhi&amp;pd_rd_r=a19f9e66-2e07-4342-8293-6c1f2087fa47\"<\/span>,\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"top_stripe_ads\"<\/span>\n                },\n                {\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 Pro (128 GB) - Natural Titanium | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBMRD1G\"<\/span>,\n                    <span class=\"hljs-attr\">\"brand\"<\/span>: <span class=\"hljs-string\">\"iPhone on Boost Infinte\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81lOtLouS4L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.5<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/aax-us-iad.amazon.com\/x\/c\/RC98KFmWsAEdxduP9dXJQTYAAAGPFqW3UAEAAAH2AQBvbm9fdHhuX2JpZDcgICBvbm9fdHhuX2ltcDEgICDgnjxr\/https:\/\/www.amazon.com\/gp\/aw\/d\/B0CHBMRD1G\/?_encoding=UTF8&amp;pd_rd_plhdr=t&amp;aaxitk=d3d8785e02cd16d1c54fa1ccc21b7282&amp;hsa_cr_id=0&amp;qid=1714071910&amp;sr=1-2-9e67e56a-6f64-441f-a281-df67fc737124&amp;ref_=sbx_be_s_sparkle_lsi4d_asin_1_bkgd&amp;pd_rd_w=2pU4D&amp;content-id=amzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b%3Aamzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_p=417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;pd_rd_wg=72Qhi&amp;pd_rd_r=a19f9e66-2e07-4342-8293-6c1f2087fa47\"<\/span>,\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"top_stripe_ads\"<\/span>\n<span class=\"hljs-string\">\"etag\"<\/span>: <span class=\"hljs-string\">\"W\/\\\"67e1-qw7jH5r29IrlzNOWtgrJyQt30i8\\\"\"<\/span>,\n            <span class=\"hljs-attr\">\"vary\"<\/span>: <span class=\"hljs-string\">\"Accept-Encoding\"<\/span>,\n            <span class=\"hljs-attr\">\"strict-transport-security\"<\/span>: <span class=\"hljs-string\">\"max-age=15724800; includeSubDomains\"<\/span>\n        },\n        <span class=\"hljs-string\">\"body\"<\/span>: {\n            <span class=\"hljs-attr\">\"ads\"<\/span>: &#91;\n                {\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Boost Infinite iPhone 15 Pro Max (256 GB) \\u2014 Natural Titanium &#91;Locked]. Requires unlimited plan starting at $60\/mo.\"<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBQTL9Z\"<\/span>,\n                    <span class=\"hljs-attr\">\"brand\"<\/span>: <span class=\"hljs-string\">\"iPhone on Boost Infinte\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81YQTED1r5L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.4<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/aax-us-iad.amazon.com\/x\/c\/RC98KFmWsAEdxduP9dXJQTYAAAGPFqW3UAEAAAH2AQBvbm9fdHhuX2JpZDcgICBvbm9fdHhuX2ltcDEgICDgnjxr\/https:\/\/www.amazon.com\/gp\/aw\/d\/B0CHBQTL9Z\/?_encoding=UTF8&amp;pd_rd_plhdr=t&amp;aaxitk=d3d8785e02cd16d1c54fa1ccc21b7282&amp;hsa_cr_id=0&amp;qid=1714071910&amp;sr=1-1-9e67e56a-6f64-441f-a281-df67fc737124&amp;ref_=sbx_be_s_sparkle_lsi4d_asin_0_bkgd&amp;pd_rd_w=2pU4D&amp;content-id=amzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b%3Aamzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_p=417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;pd_rd_wg=72Qhi&amp;pd_rd_r=a19f9e66-2e07-4342-8293-6c1f2087fa47\"<\/span>,\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"top_stripe_ads\"<\/span>\n                },\n                {\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 Pro (128 GB) - Natural Titanium | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBMRD1G\"<\/span>,\n                    <span class=\"hljs-attr\">\"brand\"<\/span>: <span class=\"hljs-string\">\"iPhone on Boost Infinte\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81lOtLouS4L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.5<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/aax-us-iad.amazon.com\/x\/c\/RC98KFmWsAEdxduP9dXJQTYAAAGPFqW3UAEAAAH2AQBvbm9fdHhuX2JpZDcgICBvbm9fdHhuX2ltcDEgICDgnjxr\/https:\/\/www.amazon.com\/gp\/aw\/d\/B0CHBMRD1G\/?_encoding=UTF8&amp;pd_rd_plhdr=t&amp;aaxitk=d3d8785e02cd16d1c54fa1ccc21b7282&amp;hsa_cr_id=0&amp;qid=1714071910&amp;sr=1-2-9e67e56a-6f64-441f-a281-df67fc737124&amp;ref_=sbx_be_s_sparkle_lsi4d_asin_1_bkgd&amp;pd_rd_w=2pU4D&amp;content-id=amzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b%3Aamzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_p=417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;pd_rd_wg=72Qhi&amp;pd_rd_r=a19f9e66-2e07-4342-8293-6c1f2087fa47\"<\/span>,\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"top_stripe_ads\"<\/span>\n                },\n                {\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 (512 GB) - Pink | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBPJYF2\"<\/span>,\n                    <span class=\"hljs-attr\">\"brand\"<\/span>: <span class=\"hljs-string\">\"iPhone on Boost Infinte\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/71SK-KD0OwL.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.1<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">0<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/aax-us-iad.amazon.com\/x\/c\/RC98KFmWsAEdxduP9dXJQTYAAAGPFqW3UAEAAAH2AQBvbm9fdHhuX2JpZDcgICBvbm9fdHhuX2ltcDEgICDgnjxr\/https:\/\/www.amazon.com\/gp\/aw\/d\/B0CHBPJYF2\/?_encoding=UTF8&amp;pd_rd_plhdr=t&amp;aaxitk=d3d8785e02cd16d1c54fa1ccc21b7282&amp;hsa_cr_id=0&amp;qid=1714071910&amp;sr=1-3-9e67e56a-6f64-441f-a281-df67fc737124&amp;ref_=sbx_be_s_sparkle_lsi4d_asin_2_bkgd&amp;pd_rd_w=2pU4D&amp;content-id=amzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b%3Aamzn1.sym.417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_p=417820b0-80f2-4084-adb3-fb612550f30b&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;pd_rd_wg=72Qhi&amp;pd_rd_r=a19f9e66-2e07-4342-8293-6c1f2087fa47\"<\/span>,\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"top_stripe_ads\"<\/span>\n                }\n            ],\n            <span class=\"hljs-attr\">\"results\"<\/span>: &#91;\n                {\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"search_product\"<\/span>,\n                    <span class=\"hljs-attr\">\"position\"<\/span>: <span class=\"hljs-number\">1<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBQTL9Z\"<\/span>,\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"iPhone 15 Pro Max (256 GB) \\u2014 Natural Titanium &#91;Locked]. Requires unlimited plan starting at $60\/mo.\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81YQTED1r5L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"section_name\"<\/span>: <span class=\"hljs-literal\">null<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">true<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.4<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">108<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/Apple-iPhone-Pro-Max-trade\/dp\/B0CHBQTL9Z\/ref=sxin_9_hcs-iphone-pl-us-1?content-id=amzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288%3Aamzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288&amp;cv_ct_cx=iPhone+15&amp;dib=eyJ2IjoiMSJ9.mkVwt1leAIWwm7eXPZKnwBipfbqLQGvzK8viyhIvuguOLaFIB9S-77bJkyElM615.TRC7OQ48MLGcWS4f-aZW2XEz5uJWCqmM-rvRAykInhM&amp;dib_tag=se&amp;keywords=iPhone+15&amp;pd_rd_i=B0CHBQTL9Z&amp;pd_rd_r=6083195e-1f49-43d0-af9a-3c827a6514c4&amp;pd_rd_w=BQaTJ&amp;pd_rd_wg=Fuoa9&amp;pf_rd_p=924d5a95-2224-4bd3-93c0-a60c9770a288&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;qid=1714071910&amp;sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&amp;sr=1-1-acced174-0150-4fc5-bcd1-b989ebc3c57d\"<\/span>,\n                    <span class=\"hljs-attr\">\"spec\"<\/span>: {},\n                    <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$0.01\"<\/span>,\n<span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                    <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">0.01<\/span>,\n                    <span class=\"hljs-attr\">\"original_price\"<\/span>: {\n                        <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$1,199.99\"<\/span>,\n                        <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                        <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">1199.99<\/span>\n                    }\n                },\n                {\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"search_product\"<\/span>,\n                    <span class=\"hljs-attr\">\"position\"<\/span>: <span class=\"hljs-number\">2<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBMRD1G\"<\/span>,\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 Pro (128 GB) - Natural Titanium | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81lOtLouS4L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"section_name\"<\/span>: <span class=\"hljs-literal\">null<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">true<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.5<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">35<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/Apple-iPhone-Pro-128-trade\/dp\/B0CHBMRD1G\/ref=sxin_9_hcs-iphone-pl-us-1?content-id=amzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288%3Aamzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288&amp;cv_ct_cx=iPhone+15&amp;dib=eyJ2IjoiMSJ9.mkVwt1leAIWwm7eXPZKnwBipfbqLQGvzK8viyhIvuguOLaFIB9S-77bJkyElM615.TRC7OQ48MLGcWS4f-aZW2XEz5uJWCqmM-rvRAykInhM&amp;dib_tag=se&amp;keywords=iPhone+15&amp;pd_rd_i=B0CHBMRD1G&amp;pd_rd_r=6083195e-1f49-43d0-af9a-3c827a6514c4&amp;pd_rd_w=BQaTJ&amp;pd_rd_wg=Fuoa9&amp;pf_rd_p=924d5a95-2224-4bd3-93c0-a60c9770a288&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;qid=1714071910&amp;sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&amp;sr=1-2-acced174-0150-4fc5-bcd1-b989ebc3c57d\"<\/span>,\n                    <span class=\"hljs-attr\">\"spec\"<\/span>: {},\n                    <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$0.01\"<\/span>,\n                    <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                    <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">0.01<\/span>,\n                    <span class=\"hljs-attr\">\"original_price\"<\/span>: {\n                        <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$999.99\"<\/span>,\n                        <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                        <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">999.99<\/span>\n                    }\n                },\n                {\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"search_product\"<\/span>,\n                    <span class=\"hljs-attr\">\"position\"<\/span>: <span class=\"hljs-number\">3<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBPTX1P\"<\/span>,\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 Plus (128 GB) - Pink | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/71iNOcZuxEL.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"section_name\"<\/span>: <span class=\"hljs-literal\">null<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">true<\/span>,\n<span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">14<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/Apple-iPhone-Plus-128-trade\/dp\/B0CHBPTX1P\/ref=sxin_9_hcs-iphone-pl-us-1?content-id=amzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288%3Aamzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288&amp;cv_ct_cx=iPhone+15&amp;dib=eyJ2IjoiMSJ9.mkVwt1leAIWwm7eXPZKnwBipfbqLQGvzK8viyhIvuguOLaFIB9S-77bJkyElM615.TRC7OQ48MLGcWS4f-aZW2XEz5uJWCqmM-rvRAykInhM&amp;dib_tag=se&amp;keywords=iPhone+15&amp;pd_rd_i=B0CHBPTX1P&amp;pd_rd_r=6083195e-1f49-43d0-af9a-3c827a6514c4&amp;pd_rd_w=BQaTJ&amp;pd_rd_wg=Fuoa9&amp;pf_rd_p=924d5a95-2224-4bd3-93c0-a60c9770a288&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;qid=1714071910&amp;sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&amp;sr=1-3-acced174-0150-4fc5-bcd1-b989ebc3c57d\"<\/span>,\n                    <span class=\"hljs-attr\">\"spec\"<\/span>: {},\n                    <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$0.01\"<\/span>,\n                    <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                    <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">0.01<\/span>,\n                    <span class=\"hljs-attr\">\"original_price\"<\/span>: {\n                        <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$929.99\"<\/span>,\n                        <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                        <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">929.99<\/span>\n                    }\n                },\n                {\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"search_product\"<\/span>,\n                    <span class=\"hljs-attr\">\"position\"<\/span>: <span class=\"hljs-number\">4<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBNXW73\"<\/span>,\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"Apple iPhone 15 (128 GB) - Pink | &#91;Locked] | Boost Infinite plan required starting at $60\/mo. | Unlimited Wireless | No trade-in needed to start | Get the latest iPhone every year\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/71SK-KD0OwL.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"section_name\"<\/span>: <span class=\"hljs-literal\">null<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">true<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.1<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">24<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/Apple-iPhone-128-Unlimited-trade\/dp\/B0CHBNXW73\/ref=sxin_9_hcs-iphone-pl-us-1?content-id=amzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288%3Aamzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288&amp;cv_ct_cx=iPhone+15&amp;dib=eyJ2IjoiMSJ9.mkVwt1leAIWwm7eXPZKnwBipfbqLQGvzK8viyhIvuguOLaFIB9S-77bJkyElM615.TRC7OQ48MLGcWS4f-aZW2XEz5uJWCqmM-rvRAykInhM&amp;dib_tag=se&amp;keywords=iPhone+15&amp;pd_rd_i=B0CHBNXW73&amp;pd_rd_r=6083195e-1f49-43d0-af9a-3c827a6514c4&amp;pd_rd_w=BQaTJ&amp;pd_rd_wg=Fuoa9&amp;pf_rd_p=924d5a95-2224-4bd3-93c0-a60c9770a288&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;qid=1714071910&amp;sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&amp;sr=1-4-acced174-0150-4fc5-bcd1-b989ebc3c57d\"<\/span>,\n                    <span class=\"hljs-attr\">\"spec\"<\/span>: {},\n                    <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$0.01\"<\/span>,\n                    <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                    <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">0.01<\/span>,\n<span class=\"hljs-attr\">\"original_price\"<\/span>: {\n                        <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$829.99\"<\/span>,\n                        <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                        <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">829.99<\/span>\n                    }\n                },\n                {\n                    <span class=\"hljs-attr\">\"type\"<\/span>: <span class=\"hljs-string\">\"search_product\"<\/span>,\n                    <span class=\"hljs-attr\">\"position\"<\/span>: <span class=\"hljs-number\">5<\/span>,\n                    <span class=\"hljs-attr\">\"asin\"<\/span>: <span class=\"hljs-string\">\"B0CHBQTL9Z\"<\/span>,\n                    <span class=\"hljs-attr\">\"name\"<\/span>: <span class=\"hljs-string\">\"iPhone 15 Pro Max (256 GB) \\u2014 Natural Titanium &#91;Locked]. Requires unlimited plan starting at $60\/mo.\"<\/span>,\n                    <span class=\"hljs-attr\">\"image\"<\/span>: <span class=\"hljs-string\">\"https:\/\/m.media-amazon.com\/images\/I\/81YQTED1r5L.jpg\"<\/span>,\n                    <span class=\"hljs-attr\">\"has_prime\"<\/span>: <span class=\"hljs-literal\">true<\/span>,\n                    <span class=\"hljs-attr\">\"is_best_seller\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_amazon_choice\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"is_limited_deal\"<\/span>: <span class=\"hljs-literal\">false<\/span>,\n                    <span class=\"hljs-attr\">\"purchase_history_message\"<\/span>: <span class=\"hljs-string\">\"300+ bought in past month\"<\/span>,\n                    <span class=\"hljs-attr\">\"stars\"<\/span>: <span class=\"hljs-number\">4.4<\/span>,\n                    <span class=\"hljs-attr\">\"total_reviews\"<\/span>: <span class=\"hljs-number\">108<\/span>,\n                    <span class=\"hljs-attr\">\"url\"<\/span>: <span class=\"hljs-string\">\"https:\/\/www.amazon.com\/Apple-iPhone-Pro-Max-trade\/dp\/B0CHBQTL9Z\/ref=sxin_9_hcs-iphone-pl-us-1?content-id=amzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288%3Aamzn1.sym.924d5a95-2224-4bd3-93c0-a60c9770a288&amp;cv_ct_cx=iPhone+15&amp;dib=eyJ2IjoiMSJ9.mkVwt1leAIWwm7eXPZKnwBipfbqLQGvzK8viyhIvuguOLaFIB9S-77bJkyElM615.TRC7OQ48MLGcWS4f-aZW2XEz5uJWCqmM-rvRAykInhM&amp;dib_tag=se&amp;keywords=iPhone+15&amp;pd_rd_i=B0CHBQTL9Z&amp;pd_rd_r=6083195e-1f49-43d0-af9a-3c827a6514c4&amp;pd_rd_w=BQaTJ&amp;pd_rd_wg=Fuoa9&amp;pf_rd_p=924d5a95-2224-4bd3-93c0-a60c9770a288&amp;pf_rd_r=0CSW0M6TC43N4C5C0AJZ&amp;qid=1714071910&amp;sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&amp;sr=1-1-acced174-0150-4fc5-bcd1-b989ebc3c57d\"<\/span>,\n                    <span class=\"hljs-attr\">\"spec\"<\/span>: {},\n                    <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$0.01\"<\/span>,\n                    <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                    <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">0.01<\/span>,\n                    <span class=\"hljs-attr\">\"original_price\"<\/span>: {\n                        <span class=\"hljs-attr\">\"price_string\"<\/span>: <span class=\"hljs-string\">\"$1,199.99\"<\/span>,\n                        <span class=\"hljs-attr\">\"price_symbol\"<\/span>: <span class=\"hljs-string\">\"$\"<\/span>,\n                        <span class=\"hljs-attr\">\"price\"<\/span>: <span class=\"hljs-number\">1199.99<\/span>\n                    }\n                }, Truncated to the first <span class=\"hljs-number\">5<\/span> results...\n            }\n            ],\n            <span class=\"hljs-attr\">\"explore_more_items\"<\/span>: &#91;],\n            <span class=\"hljs-attr\">\"next_pages\"<\/span>: &#91;]\n        },\n        <span class=\"hljs-string\">\"statusCode\"<\/span>: <span class=\"hljs-number\">200<\/span>,\n        <span class=\"hljs-string\">\"credits\"<\/span>: <span class=\"hljs-number\">5<\/span>\n    }\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\"><strong>Keep Learning<\/strong><\/h2>\n\n\n\n<p>You&#8217;ve seen how easy it is to make POST requests to websites or APIs using Requests, and how we can reduce much of the common code in our applications by using it. By following this guide, you should now have a solid understanding of how to send POST requests using Python.<\/p>\n\n\n\n<p>We learned how to send JSON data using parameters like <strong>&#8216;data&#8217;<\/strong>, <strong>&#8216;json&#8217;<\/strong>, or <strong>&#8216;files&#8217;<\/strong>, and even built real-world projects using POST requests with ScraperAPI. To further enhance your knowledge, we encourage you to explore the following resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/docs.python-requests.org\/en\/latest\/\" target=\"_blank\" rel=\"noopener\">Requests Documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.scraperapi.com\/documentation?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\">ScraperAPI Documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.scraperapi.com\/?fp_ref=rajesh37\" target=\"_blank\" rel=\"noopener\">ScraperAPI page<\/a><\/li>\n<\/ul>\n\n\n\n<div data-wp-interactive=\"core\/file\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!state.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/How-to-Send-a-Post-Request-with-Python-for-ScraperAPI-\u2013-DevOps-School-article.pdf\" type=\"application\/pdf\" style=\"width:100%;height:2000px\" aria-label=\"Embed of How to Send a Post Request with Python for ScraperAPI \u2013 DevOps School article.\"><\/object><a id=\"wp-block-file--media-647e74ae-f5ac-4654-9b67-ae4cf8b87431\" href=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/How-to-Send-a-Post-Request-with-Python-for-ScraperAPI-\u2013-DevOps-School-article.pdf\">How to Send a Post Request with Python for ScraperAPI \u2013 DevOps School article<\/a><a href=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2024\/08\/How-to-Send-a-Post-Request-with-Python-for-ScraperAPI-\u2013-DevOps-School-article.pdf\" class=\"wp-block-file__button wp-element-button\" aria-describedby=\"wp-block-file--media-647e74ae-f5ac-4654-9b67-ae4cf8b87431\" download>Download<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Most tutorials focus on GET requests, but working with an API frequently requires using POST requests as well. Web servers don\u2019t randomly send data; a request must be made&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-46784","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46784","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=46784"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46784\/revisions"}],"predecessor-version":[{"id":46792,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/46784\/revisions\/46792"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=46784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=46784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=46784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}