До некоторых пор код отлично работал. Теперь возвращает ответ 403.
Кто-нибудь знает как исправить?
import requests
import json
def main():
ids = [4570694029, 3203317426, 4546274771, 4611188675]
for i in ids:
url = 'https://api.domofond.ru/rpc'
data = {"id":"1", "jsonrpc":"2.0", "method":"item.GetItemPhoneV1", "params":{"meta":{"platform":"web","language":"ru"},"id":i,"itemType":"Listing"}}
data = json.dumps(data)
headers={"Host": "api.domofond.ru",
"User-Agent": "Mozilla/5.0",
"Accept": "*/*",
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate, br",
"Referer": "https://www.domofond.ru/2-komnatnaya-kvartira-na-prodazhu-sankt_peterburg-4611188675",
"Content-Type": "text/plain",
"X-Request-Id": "b04f3c5b-378a-45fc-b382-0c88d2c885bd",
"Origin": "https://www.domofond.ru",
"Content-Length": "147",
"Connection": "keep-alive",
"Cookie": "dfuid=4952dc07-cedd-4723-8825-692441fd1677; _ga=GA1.2.207709362.1630835300; rrpvid=988184375939883; rcuid=61349266c783820001ac3e67; duid=xndoXW0qrC64ZSjlXXSSl7JFtUv0awhLYlj24MLfWfjl4tio; _gid=GA1.2.809471283.1643743940; cto_bundle=6iKxGl9SQ3U3dFJPQzJDWnJlTmtXclg5MlJEUFRsJTJCUyUyRmxPZGtFdyUyQiUyQmhLNlJRSTFyMHRGeUtISSUyQnlRVkpvVFNSOEROY1dlemtGQXNsMlN1eUU0TmtTcDZKZlZicU12QmRBZGJrRnpzb2pNRVJROWhpSFlZV2Q2WjZxYUtwNGNOUTJyaVNIN3FzbTExREpQZkFOTGo4ZUx5JTJGTVElM0QlM0Q; rr-viewItemId=2330241172; rrviewed=2322634746%2C2103317227%2C2308774220%2C2330241172; rrlevt=1643744013897",
"TE": "Trailers",
"Pragma": "no-cache",
"Cache-Control": "no-cache"}
r = requests.post(url, data=data, headers=headers)
print(r.json)
# json_string = json.loads(r.text)
print(json_string['result']['phone'])
if __name__ == '__main__':
main()