35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from playwright.sync_api import sync_playwright
|
|
import json
|
|
|
|
def run():
|
|
with sync_playwright() as p:
|
|
try:
|
|
# Пробуем 127.0.0.1 вместо localhost для надежности
|
|
browser = p.chromium.connect_over_cdp('http://127.0.0.1:9222')
|
|
page = browser.contexts[0].pages[0]
|
|
|
|
data = []
|
|
# Используем query_selector_all для простоты
|
|
rows = page.query_selector_all('tr')
|
|
print(f'DOM Rows: {len(rows)}')
|
|
|
|
for row in rows:
|
|
text = row.inner_text()
|
|
if '73-20' in text:
|
|
# Ищем ссылку внутри строки
|
|
link = row.query_selector('a[href*="appeals/view/"]')
|
|
if link:
|
|
number = link.inner_text().strip()
|
|
href = link.get_attribute('href')
|
|
data.append({'number': number, 'href': href})
|
|
|
|
with open('/app/queue.json', 'w', encoding='utf-8') as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
|
|
print(f'Captured: {len(data)}')
|
|
browser.close()
|
|
except Exception as e:
|
|
print(f'ERROR: {e}')
|
|
|
|
if __name__ == '__main__':
|
|
run()
|