Skip to content

Commit 18ab9ea

Browse files
committed
Update example according to comments
1 parent 429b913 commit 18ab9ea

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/run_script_in_headless_browser/run_in_headless_browser.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@ def main():
2525
# Launch the browser in headless mode
2626
browser = playwright.chromium.launch(headless=True)
2727

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
3030

3131
page.goto(URL)
3232

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
3534
response = page.query_elements(QUERY)
3635

36+
# Use Playwright's API to fill the search box and click the search button
3737
response.search_input.fill("President of United States")
38-
3938
response.search_btn.click(force=True)
4039

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
4241
response = page.query_data(QUERY_2)
4342

4443
print(response)

0 commit comments

Comments
 (0)