Exit/termination processor
Core v2.2.0
The
processor immediately terminates scraper execution, optionally
with a custom message. It's useful for early termination on errors, completion conditions,
or when specific data is found.
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="response">
<http url="https://api.example.com/data"/>
</def>
<if condition="${empty(response)}">
<exit message="API returned empty response - terminating"/>
</if>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<loop item="item" maxloops="1000">
<xpath expression="//item">...</xpath>
<if condition="${item == 'TARGET'}">
<file path="found.txt" action="write">Found target: ${item}</file>
<exit message="Target item found, stopping search"/>
</if>
</loop>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://org.webharvest/schema/2.1/core">
<def var="requestCount" value="0"/>
<while condition="${hasMore}">
<http url="https://api.example.com/data"/>
<def var="requestCount">
<script>parseInt(context.getVar("requestCount")) + 1</script>
</def>
<if condition="${requestCount >= 100}">
<exit message="Request quota reached (100 requests)"/>
</if>
</while>
</config>