How to go to specific block if key exist/does not exist?

I’m parsing multiple keyword search on a newspaper website.

How can I do it so that if my first keyword result is 0 to skip to a certain block?

BLOCK:HttpRequest
  url = "https://website.com/query=keyword"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Keycheck
  KEYCHAIN CUSTOM OR
    STRINGKEY @data.SOURCE Contains "null"
  KEYCHAIN SUCCESS OR
    STRINGKEY @data.SOURCE Contains "result"
ENDBLOCK

BLOCK:Parse
  input = @data.SOURCE
  leftDelim = "result"
  jToken = "resultid"
  MODE:Json
  => VAR @results
ENDBLOCK

BLOCK:HttpRequest
  url = $"https://website.com/download=<results>"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:HttpRequest
  url = "https://website.com/query=keyword2"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Keycheck
  KEYCHAIN CUSTOM OR
    STRINGKEY @data.SOURCE Contains "null"
  KEYCHAIN SUCCESS OR
    STRINGKEY @data.SOURCE Contains "result"
ENDBLOCK

BLOCK:Parse
  input = @data.SOURCE
  leftDelim = "result"
  jToken = "result"
  MODE:Json
  => VAR @results2
ENDBLOCK

BLOCK:HttpRequest
  url = $"https://website.com/download=<results2>"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

I want to go to the second search if the result of the first request is CUSTOM and skipping the other blocks.

try configuring that the bot does not stop even when the key is personalized.

image

or try using this

image

an apology if it is not a great solution because I try to replicate what you have in mind…

Look into the JUMP statement, there is an explanation in the LoliCode docs

1 Like

The keycheck block puts an end to all operations if you want to work around this you have to do it before the keycheck block.
In your case the Custom Key is “null”

IF STRINGKEY @data.SOURCE Contains "null" // Here "PUT YOUR CUSTOM KEY" 
data.STATUS = "CUSTOM"; // Set the status to CUSTOM
JUMP #ONE // By doing this we have defined a JUMP
END

If you want to call this jump you just have to write #ONE at the desired location

1 Like

It’s working. Thank you very much!