Skip to main content

Frequently Asked Questions

Q. While writing AgentQL Script, how do I ensure the web page is loaded entirely

Ans: Loading web page entirely right now is considered as an application logic, as it is difficult to objectively tell what does it mean that entire web page is loaded. As some websites have lazy loading and are infinitely scroablle and so for those kind of web pages what does it mean to load the entire web page.

Thus, right now we give this ability to users to decide and choose how much they would like to scroll. By default we scroll 3 pages and we expose APIs scroll_up(px: Optional = 720) and scroll_down(px: Optional = 720) for users to decide how and when they would like to scroll in their AgentQL script.

Q. How do I make sure that my script waits enough for all the element to appear on the page

Ans: The interim solution for this if you run into this issue is addding sleep() to your code. Following is a sample script and usage of sleep to depict how it could be leveraged. You could add sleep based on your requirements. You can approximately set the sleep timeout as of now.

import time
import agentql

QUERY = """
{
search_box
videos[] {
related_video_name
}
}
"""

time.sleep(5)
session = agentql.start_session("https://www.youtube.com/watch?v=qQkBeOisNM0")
response = session.query(QUERY)

try:
log.debug(f"Successfully received AgentQL: \n{response}")

response.search_box.fill("tinyfish")
response.search_btn.click(force=True)
except Exception as e:
log.error(f"Found Error: {e}")

session.stop()