File size: 1,173 Bytes
c1e15bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import asyncio
from playwright.async_api import async_playwright

async def extract_bootstrap_data():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()

        # Navigate to the Pixabay Sound Effects page
        await page.goto('https://pixabay.com/sound-effects/search/door%20creaking/')

        # Wait for the content to load (you can adjust the timeout as needed)
        # await page.wait_for_selector('.js-media-list-wrapper')
        # await page.wait_for_selector('.js-media-item')

        # Get the content of the 5th script tag
        # script_content = await page.evaluate('''() => {
        #     const scripty=document.querySelectorAll('script')[0];
        #     return scripty.content
        # }''')
        # print(script_content)
        # await page.evaluate(f'''{script_content}(''')
       
        page_content = await page.content()
        # Print the content of the 5th script tag
        # print(page_content)

        # Close the browser
        await browser.close()

# Run the extraction function
if __name__ == '__main__':
    asyncio.run(extract_bootstrap_data())