написал скрипт который парсит данные с JSON но он этого не делает помогите вот скрипт - вопрос №5286229

Import requests from bs4 import BeautifulSoup import re import asyncio iframe = 'https://slaves-app.ru/index.php?vk_access_token_settings=friends&vk_app_id=7804694&vk_are_notifications_enabled=1&vk_is_app_user=1&vk_is_favorite=1&vk_language=ru&vk_platform=android_external&vk_ref=other&vk_ts=1694947497&vk_user_id=328196639&sign=qNs8q_7kTaefRUHpK9b6bhTZSIR9fnezw7JQBqRiApU' victim = 488476489 headers = { «content-type»: «application/x-www-form-urlencoded; charset=UTF-8», «x-requested-with»: «XMLHttpRequest» } def query_to_str(obj): return "&".join([f"{key}={val}" for key, val in obj.items()]) async def post(method, parameters): response = requests.post(iframe.replace('index', 'api'), headers=headers, data=query_to_str(parameters) + f"&method={method}&rhash={rhash['response']}") return response.json() async def profile(id): first = await post('getMarket.v3', {'friends': id}) try: hash_value = first[0]['hash'] vkid = first[0]['id'] second = await post('profile', {'vkid': vkid, 'hash': hash_value}) return second except (IndexError, KeyError, TypeError) as e: print(f«Error in profile function: {e}») return {} async def give_rhash(): try: response = requests.get(iframe) soup = BeautifulSoup(response.text, 'html.parser') n_doc = soup.select(«head > script:nth-child(11)»)[0].text data = n_doc.replace(" ", "").replace("\n", "").replace("\t", "") match = re.search(r'[a-f0-9]{32}', data) if match: l_hash = match.group(0) finish = None for its_lhash in l_hash: response = requests.post( iframe.replace('index', 'api'), headers=headers, data=f«notify=false&lhash={its_lhash}&im_slave=391808834&system=true&method=info» ) res = response.json() if isinstance(res['res'], str): finish = {'connect': False, 'response': res['res']} else: finish = {'connect': True, 'response': res['res']['hash']} if finish['connect']: return finish return {'connect': False, 'response': 'No data found'} except (IndexError, KeyError, TypeError) as e: print(f«Error in give_rhash function: {e}») return {'connect': False, 'response': str(e)} async def infern_top(): global rhash rhash = await give_rhash() try: if not rhash['connect']: raise Exception(«Ошибка при подключении к рабству: » + rhash['response']) except Exception as e: print(e) return info = await profile(victim) try: if isinstance(info['res'], str): raise Exception(«Ошибка в получении профиля жертвы: » + info['res']) except Exception as e: print(e) return print('Это', info['res'].get('name', 'Нет данных'), 'Баланс:', info['res'].get('balance', 'Нет данных'), 'Стоит:', info['res'].get('cost', 'Нет данных'), 'В рабстве:', info['res'].get('is_myslave', 'Нет данных'), 'Рейтинг:', info['res'].get('rating', 'Нет данных'), 'Количество рабов:', info['res'].get('slaves_count', 'Нет данных'), 'Играет за клан:', info['res']['group'].get('name', 'Нет данных')) print('рабы со стенки', info['res'].get('name', 'Нет данных'), info['res'].get('slaves', 'Нет данных')) if __name__ == "__main__": asyncio.run(infern_top())
04.10.23
0 ответов
Ответов пока нет

Михаил Александров

от 0 p.
Сейчас на сайте
Эксперт месяца
Читать ответы

Евгений

от 0 p.
Сейчас на сайте
Читать ответы

Андрей Андреевич

от 70 p.
Читать ответы
Посмотреть всех экспертов из раздела Учеба и наука
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store