File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
examples/wait_for_entire_page_load Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change 4
4
from playwright .sync_api import sync_playwright
5
5
6
6
# Yotube video URL to demonstrate the example for loading comments on the video
7
- URL = "https://www.youtube. com/watch?v=F6hmwkI3n64 "
7
+ URL = "https://duckduckgo. com/?q=machine+learning+lectures+mit&t=h_&iar=videos&iax=videos&ia=videos "
8
8
9
9
QUERY = """
10
10
{
11
- comments [] {
12
- comment_content
13
- author
14
- date
11
+ videos(first 10 videos) [] {
12
+ video_title
13
+ length
14
+ views
15
15
}
16
16
}
17
17
"""
@@ -25,16 +25,16 @@ def main():
25
25
page : Page = browser .new_page ()
26
26
page .goto (URL )
27
27
28
- for _ in range (3 ):
29
- # Wait for the page to load (helps to load the comments on the video )
28
+ for _ in range (2 ):
29
+ # Wait for the page to load (helps to load the additional videos )
30
30
page .wait_for_page_ready_state ()
31
- # Scroll down the page to trigger loading of comments
32
- page .keyboard .press ("PageDown " )
31
+ # Scroll down the page to trigger loading of more videos
32
+ page .keyboard .press ("End " )
33
33
34
34
response = page .query_data (QUERY )
35
35
36
- # Print the first comment
37
- print (response ["comments " ][0 ])
36
+ # Print the first video details
37
+ print (response ["videos " ][0 ])
38
38
39
39
browser .close ()
40
40
You can’t perform that action at this time.
0 commit comments