Действительно, используя инспектор браузера, я мог получать данные с этого сервера. Вот рабочий код, который я получил, скопировав запрос cURL
из моего браузера в Python конвертер https://curl.trillworks.com/
import requests
cookies = {
'wordpress_test_cookie': 'WP+Cookie+check',
'_ga': 'GA1.2.1193786784.1588060314',
'_gid': 'GA1.2.1185668591.1588060314',
'_gat': '1',
}
headers = {
'Connection': 'keep-alive',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Origin': 'https://covid19index.in',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://covid19index.in/district-wise-cases/',
'Accept-Language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
}
params = (
('action', 'get_wdtable'),
('table_id', '21'),
)
data = {
'draw': '1',
'columns[0][data]': '0',
'columns[0][name]': 'state',
'columns[0][searchable]': 'true',
'columns[0][orderable]': 'false',
'columns[0][search][value]': '',
'columns[0][search][regex]': 'false',
'columns[1][data]': '1',
'columns[1][name]': 'district',
'columns[1][searchable]': 'true',
'columns[1][orderable]': 'false',
'columns[1][search][value]': '',
'columns[1][search][regex]': 'false',
'columns[2][data]': '2',
'columns[2][name]': 'date',
'columns[2][searchable]': 'true',
'columns[2][orderable]': 'false',
'columns[2][search][value]': '',
'columns[2][search][regex]': 'false',
'columns[3][data]': '3',
'columns[3][name]': 'date_total',
'columns[3][searchable]': 'true',
'columns[3][orderable]': 'false',
'columns[3][search][value]': '',
'columns[3][search][regex]': 'false',
'start': '0',
'length': '-1',
'search[value]': '',
'search[regex]': 'false',
'wdtNonce': 'cee9844d13'
}
response = requests.post('https://covid19index.in/wp-admin/admin-ajax.php', headers=headers, params=params, cookies=cookies, data=data)
И данные доступны:
import ast
>>> ast.literal_eval(response.content.decode("utf-8"))["data"]
[['Andaman and Nicobar Islands',
'North and Middle Andaman',
'27\\/03\\/2020',
'1'],
['Andaman and Nicobar Islands', 'South Andaman', '26\\/03\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '27\\/03\\/2020', '4'],
['Andaman and Nicobar Islands', 'South Andaman', '28\\/03\\/2020', '3'],
['Andaman and Nicobar Islands', 'South Andaman', '30\\/03\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '08\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '17\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '18\\/04\\/2020', '2'],
['Andaman and Nicobar Islands', 'South Andaman', '19\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '20\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '21\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '22\\/04\\/2020', '1'],
['Andaman and Nicobar Islands', 'South Andaman', '23\\/04\\/2020', '4'],
...