Actor runs endlessly and only stops when aborted

import os
import re

from apify_client import ApifyClient
from bs4 import BeautifulSoup
import requests

asin = input("Enter ASIN: ")
page = requests.get(f"https://www.amazon.com/dp/%7Basin%7D%22).text
doc = BeautifulSoup(page, 'html.parser')

book = []

title_find = doc.select("[id=centerCol] h1")
title = str(title_find).split(">")[2].split("<")[0]
price_find = doc.select("[id=tmmSwatches] ul li span:nth-of-type(2)")
price = str(price_find).split("span")[2].split(">")[-1].split("<")[0]
pub_find = doc.select("[id=detailBullets_feature_div] ul li span:nth-of-type(2)")
pub = str(pub_find).split("<span")[2].split(">")[1].split("<")[0]
image_find = doc.select("[id=ebooks-img-canvas] img")[1]
image = str(image_find).split(""")[-4]
book = ["Title: " + title, "Price: " + price, "Publisher: " + pub, "Image: " + image]
for r in book:
  print(r)

Initialize the main ApifyClient instance
client = ApifyClient(os.environ['APIFY_TOKEN'], api_url=os.environ['APIFY_API_BASE_URL'])

Get the resource subclient for working with the default dataset of the actor run
default_dataset_client = client.dataset(os.environ['APIFY_DEFAULT_DATASET_ID'])

Finally, push all the results into the dataset
default_dataset_client.push_items(book)

print(f'Results have been saved to the dataset with ID {os.environ["APIFY_DEFAULT_DATASET_ID"]}')

I'm not sure why it's not finishing. It runs fine when I run it as a Python program. I've tried using the BBC weather actor tutorial as a guide but I'm stumped. What am I doing wrong here? Any help or point in the right direction would be appreciated. Thank you.
Was this page helpful?