This repository has a wide variety of example code using Dendrite that you can try out of the box.
# Start the Dendrite browser
browser = Dendrite()
# Navigate to google
browser.goto("https://google.com")
try:
browser.click("Reject all cookies")
except DendriteException:
print("No reject all cookies button found")
# Google search "hello world"
browser.fill("Search input field", "hello world")
browser.press("Enter")
# Extract the search results as a list of dicts with url and title
results = browser.extract("The search results as a list of dicts with url and title")
print(results)
Let's get started. First, we're going to install the required packages.
pip install -r requirements.txt
If you are using poetry, run the following:
poetry install
Now, lets install the web driver for running the Dendrite client locally. If you used pip to install the packages, run:
dendrite install
If you used Poetry, run:
poetry run dendrite install
Finally, you'll need a Dendrite API key, you can get your API key here.
Some examples require more API keys, like Anthropic, to run correctly. See the .env.examples
file in the root directory for reference on which keys you'll need.
Now you can simply run any python file in the repository! Feel free to experiment and modify the scripts. We recommend starting with quickstart/hello_world.py
.
If you have any questions, check out our documentation or get help in our Discord.