File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
examples/run_script_in_headless_browser Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,19 @@ def main():
25
25
# Launch the browser in headless mode
26
26
browser = playwright .chromium .launch (headless = True )
27
27
28
- # Create a new AgentQL page instance in the browser for web interactions
29
- page : Page = browser .new_page ()
28
+ # Create a new page in the broswer and cast it to custom Page type to get access to the AgentQL's querying API
29
+ page : Page = browser .new_page () # type: ignore
30
30
31
31
page .goto (URL )
32
32
33
- # Use query_elements() method to fetch the search box and button from the page
34
-
33
+ # Use query_elements() method to locate the search box and search button from the page
35
34
response = page .query_elements (QUERY )
36
35
36
+ # Use Playwright's API to fill the search box and click the search button
37
37
response .search_input .fill ("President of United States" )
38
-
39
38
response .search_btn .click (force = True )
40
39
41
- # Use query_data() method to fetch the URLs from the page
40
+ # Use query_data() method to fetch the president name from the page
42
41
response = page .query_data (QUERY_2 )
43
42
44
43
print (response )
You can’t perform that action at this time.
0 commit comments