Sending a POST request in Python does not modify the original date displayed in the response

view image description hereWhen attempting to submit form data on the , I receive a response, but it doesn't reflect the dates I provided in my post. Below is the code snippet I am using:

import requests.sessions
url = "https://seffaflik.epias.com.tr/transparency/piyasalar/gop/ptf.xhtml"
aaa = {"j_idt202": "j_idt202",
"j_idt202:date1_input": "15.04.2020",
"j_idt202:date2_input": "17.04.2020",
"j_idt202:goster": "",
"j_idt202:dt_rppDD": "24",
"javax.faces.ViewState": "-4553737376077641878:8530200118323030971"}
bbb = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Content-Length": "192",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": "JSESSIONID=pRJV7cTKKZBG7umanw-d7LLA5dTvfTd52EDzotlR.prd-transparency-n40; TS015dca6c=01cbc7c0b2c35901079ad1afda5dd13dad6a6f5cc4fcaa1cb200890b1e0401d54b571361e1ceea05c8afd884fc986fa67b08b13d13f8c60c97fff85d2e811da2a543cdf9f8; _ga=GA1.3.1509483381.1584105112; _gid=GA1.3.986020094.1587121047; TS01f69930=01cbc7c0b2ab45c0fe95c9305e91aa235e908d80dec19f4d76119e4e3058ae32aac517c2048199e58051222727e2fe312518660537; _gat=1",
"Host": "seffaflik.epias.com.tr",
"Origin": "https://seffaflik.epias.com.tr",
"Referer": "https://seffaflik.epias.com.tr/transparency/piyasalar/gop/ptf.xhtml",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"}
r = requests.post(url, data= json.dumps(aaa), headers = bbb)
print(r.text)

Despite submitting the dates 15.04.2020 and 17.04.2020, the response still reflects the current date as opposed to the ones I specified. Any insights or ideas on how to resolve this issue would be greatly appreciated.

Answer №1

After making some adjustments to the parameters in the form data section of a similar webpage, I found that it successfully worked.

In order for the method mentioned above to work, the data being fetched must be simple static data without any JavaScript code execution involved in retrieving it. It's important to note that the request module essentially sends an HTTP request to a specified URL with given headers and parameters, then responds with whatever the server provides.

If you want to achieve what you're looking for, you'll need to utilize web APIs where you can define filters for the data you require and the server will respond with the appropriate information (an example can be found here). Unfortunately, the site you mentioned does not have this capability. An alternative approach would be to explore Headless Web Automation, where a browser instance is launched to fetch the requested data. You may want to do further research on this concept.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Show a dynamic tally in the terminal with a visual bar for easy tracking

Looking to create a basic command-line monitoring tool in Python that visually displays a tally on the shell. The specific tally is related to messages on a queue, but the focus is on showcasing a visual representation of this tally with the ability to inc ...

Removing identical sections that have the same starting and ending points using Python or Shell

I'm just starting out with Python and I have a text file that contains some definitions like the following: .subckt inv a z mp z a vdd vdd pch mn z a gnd gnd nch .ends .subckt pg in out clk clkb mp in clkb out vdd pch mn in clk out gnd nch .ends .s ...

Can anyone tell me why the file content disappears whenever I try to save my modifications in Python?

In my file test_final.txt, I have a collection of simple words and sentences that I want to shuffle using the shuffle method. However, when I implement the code, it empties out my test_final.txt. Additionally, I am struggling to understand why the Shuffle ...

Exploring the potential of Django to efficiently implement multiple listviews on a single webpage

Recently started working with Python and Django, but I may have bitten off more than I can chew. If anyone has the time to help educate me, I would greatly appreciate it. My main model deals with "work orders," each of which is linked to subsets of data. I ...

Simultaneously managing both stepper motors and a camera

What is the optimal method for simultaneously controlling a stepper motor and camera? Imagine having a camera mounted on a linear stage driven by a stepper motor, with the goal of moving the stage in 1mm increments while capturing an image at the end of e ...

What could be causing this error to appear when I try to run the makemigrations command?

from django.db import models # Defining the Products model class Products(models.Model): title = models.TextField() description = models.TextField() price = models.TextField() An issue has arisen and I am unsure why. Here is the error messag ...

Determine the upload date of all channel videos using yt_dlp

Is it possible to extract the upload date in a json for all videos of a channel? I am looking to get a json output that includes the upload dates of all videos. Here is the code I have: import json import yt_dlp as youtube_dl options = {'ignoreerrors ...

Looking to iterate through a dataframe and transform each row into a JSON object?

In the process of developing a function to transmit data to a remote server, I have come across a challenge. My current approach involves utilizing the pandas library to read and convert CSV file data into a dataframe. The next step is to iterate through t ...

Ways to determine if a date matches today's date within a component template

I am currently displaying a list of news articles on the webpage and I want to show the word "Today" if the news article's date is equal to today's date. Otherwise, I want to display the full date on the page. Is there a way to compare the news.D ...

SQLAlchemy: Sorting data based on the result of a different order by query

I have a table called Fulfillment with two columns: status and creation date. My goal is to display the data in descending order by creation date if the status is 'open', and ascending order by creation date if the status is 'closed'. A ...

What is the best way to determine if a character is valid for use in HTML rendering?

There are certain characters, like ordinal 22 or 8, that do not appear correctly in HTML (when using Chrome for example when copying and pasting them into this 'Ask question' editor; assuming utf-8 encoding). How can I identify which characters a ...

What are some effective ways to extract additional information from lxml error messages?

Due to the inability to use an XSL IDE, I have developed a simple Python script utilizing lxml in order to convert XML files using a specified XSL transformation and save the output to a new file. Here is the code snippet (excerpted): p = XMLParser(huge_t ...

Acquire an element in Selenium by utilizing the "data-testid" attribute

I am attempting to extract data from each HTML element that has a specific data-testid attribute, which is as follows: <div data-testid="sl.explore.card-description"></div> The code I have written for this purpose is shown below, but ...

Jupyter notebook fails to display the plot

Recently, I delved into learning Python and decided to teach myself how to utilize pandas in Jupyter by following the exercises in this fascinating link: A peculiar issue arose when I attempted to plot at section 1.3 in Jupyter, as only the following outp ...

What is the best way to eliminate the specific element containing our desired word from the webpage data extracted through selenium?

After scraping 6 elements from a website using the Selenium find_element(By.XPATH) module, I stored these elements in a list. I then converted these elements into text and searched on Google. However, due to the ever-changing nature of the elements, somet ...

Automating pagination with Selenium

Currently, I am experimenting with using selenium to automate pagination by navigating through "next" buttons. My goal is to apply this technique on a large scale, potentially spanning hundreds of pages. While I have successfully implemented the functional ...

Pyinstaller is throwing an error message stating that it is unable to load AutoItX from the

When running my program from the command line, everything works perfectly fine. Now I need to create an Executable file, so I attempted to use pyinstaller. However, it seems that pyinstaller is unable to recognize the autoit module when automatically analy ...

How to automatically interact with cookie consent popups using Selenium?

As a newcomer to web scraping, I decided to embark on a small project of automating the login process for Instagram. Using Chrome Web Driver and Selenium, I managed to open the Instagram page successfully. However, I encountered an issue with automating a ...

Using Selenium in Python to extract distinct list

I'm currently working on a script to scrape hotel.com using selenium import time import os from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webd ...

Dealing with Media Recorder File Types in FastAPI WebSockets - Trouble with Video File Integrity问题

Currently, I am working on a project that involves using FastAPI to manage WebSocket connections for receiving video blobs from a Media Recorder. The main objective is to divide the video into parts with a size limit of 5 MB and save each part as a separat ...