In this notebook, we will assume that we’re running a company selling a product - vacuum cleaners -, and we want to monitor our competitors, by looking at the positive and negative reviews that their products are receiving and latest product announcements.
We’ll define a helper function that waits until the task is completed. The /browse endpoint is asynchronous, therefore we need to poll /task/{taskId} until the task is completed
For the first step, we’ll check Amazon to find the reviews
deflaunch_amazon_task(): amazon_task_ids =[]for competitor in name_of_competitors:print(f"Getting reviews for {competitor}") response = requests.post( url=browse_endpoint, headers={"x-api-key": twin_key}, json={"goal":f"Find the latest reviews for {competitor}'s most popular vacuum cleaner - summarize the points made in the most positive and negative ones","startUrl":"https://www.amazon.com/",},) amazon_task_ids.append(response.json()["taskId"])return amazon_task_idsamazon_task_ids = launch_amazon_task()amazon_reviews = wait_for_tasks(amazon_task_ids)
for review, competitor inzip(amazon_reviews, name_of_competitors):print(f"# Reviews for {competitor}")print(review)print("-"*100)print("\n\n")