import io from playwright.sync_api import sync_playwright out = io.open('_mt_out.txt', 'w', encoding='utf-8') with sync_playwright() as p: b = p.chromium.launch() pg = b.new_page() pg.goto('https://www.metacareers.com/jobs?offices[0]=Zurich%2C%20Switzerland', wait_until='domcontentloaded', timeout=60000) pg.wait_for_timeout(9000) for _ in range(6): pg.mouse.wheel(0, 5000); pg.wait_for_timeout(1200) n = pg.locator("a[href*='/jobs/']").count() n2 = pg.locator("a[href*='/profile/job_details/']").count() out.write('a[/jobs/]=%d a[/profile/job_details/]=%d\n' % (n, n2)) for i in range(min(n, 30)): el = pg.locator("a[href*='/jobs/']").nth(i) out.write(' %s | %s\n' % ((el.inner_text() or '').replace('\n', ' / ')[:90], (el.get_attribute('href') or '')[:60])) out.write('---TEXT---\n' + pg.inner_text('body')[:900]) b.close() out.close()