Stop subpage loop early when email is found (move to next website)

Hey everyone,

I’m currently building a workflow that extracts email from the subpages of each website and stores it in a Google Sheet.

Describe the problem/error/question

The problem I’m facing is that even after an email is found, the workflow continues to loop through all the remaining subpages of that website and doesn’t proceed to the next website in the list.

I want the loop to stop immediately once an email is found, update the row, and then start processing the next website.

What is the error message (if any)?

The workflow runs without errors, but the inner loop (Loop Over Subpages) passes the subpages of the next website forward and the “Split Subpages → HTTP” part simply doesn’t process them.

Please share your workflow

Share the output returned by the last node

The workflow stops in the outer loop (i.e., Loop Over Websites). The “Done Branch” of this loop has 97 items in total.

[
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "found": false
  },
  {
    "found": false
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "Email": "support@thegreenark.co.uk",
    "row_number": 2,
    "Grantmaker Name": "TheGreenArk Ltd",
    "Website URL": "https://thegreenark.co.uk"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/enroll/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/inscribase-en-great-hearts/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/great-hearts-curriculum/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/enroll/enrolling-your-kindergarten-student/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/special-education/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/physical-education-athletics/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/co-curricular-programs/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/summer-programs/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/results/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/college-counseling/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/mental-health/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/bullying/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/academies/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/people/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-core-purpose/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/great-hearts-philosophy/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/people/leadership-team/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/people/academy-headmasters/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/people/press-room/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-great-stories/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/contact-us/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/a-sweet-victory-at-the-north-phoenix-prep-root-beer-mile/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-cheer-clinics-bring-energy-enthusiasm-and-skills/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/2026-national-symposium-launches-pre-conference-on-making-classical-education-accessible-for-all-learners/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/seniors-at-great-hearts-forest-heights-start-the-school-year-with-a-new-tradition/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/u-s-secretary-of-education-linda-mcmahon-visits-great-hearts-harveston/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/first-day-of-school-at-young-hearts-preschool-in-scottsdale/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/great-hearts-life/events/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/annualreport/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/alumni/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/finance-compliance/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/report-a-problem/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/wp-content/uploads/2024/05/Accessibility-Statement-for-Great-Hearts-Academies.pdf/uploads/2020/03/Accessibility-Statement-for-Great-Hearts-Academies-3.pdf"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/public-information-requests/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/average-teacher-salaries/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/privacy-policy/"
  },
  {
    "subpageUrl": "https://www.greatheartsamerica.org/rfp/"
  }
]

Information on your n8n setup

  • n8n version: 1.99.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker Compose
  • Operating system: Windows 10

P.S., I am trying to share the code of the workflow, but I keep getting a 403 error.

Hey @awon08 hope all is good. Welcome to the community.

The easiest way I found to implement this is to split the execution into two workflows:

First workflow (produces webpages each containing subpages, see pinned manual trigger):

The other workflow is a consumer, which takes the webpage with subpages, iterates over said subpages and as soon as it finds one with email it responds to the webhook:

This was tested with my mock server, which obviously produces info very different from yours, but I hope this approach can help you with the architecture and general idea.

I will keep the mock running for a little while, so if you would like to run to test and see how it’s working, feel free to.

Thanks Jabbson for the helping hand. What I’m trying to do in this workflow is take the website URL, search through X number of subpages, and have the crawler go through those subpages until it finds an email on any of them and then store that email in Google Sheets. This is how I was able to make it work using a sub-workflow.

Main workflow:

Sub-workflow:

Your suggestion was a light bulb moment. Huge thanks to you!