Results File Question

Discussion in 'A-Parser Support Forum' started by scrapefun, Nov 4, 2017.

  1. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Using net:http parser, I'm performing two queries on Google per keyword and saving both results to the same file like this:

    Code:
    [% IF p1.info.success == 1;
        IF query.lvl ==0;
            p1.data _ "\n<!-- PAGE_SEPARATE -->\n";
        ELSE;
            p1.data _ "\n";
        END;
    END;
    USE Math;
    dir = Math.int(query.num / 2000);
    tools.query.add(query.first _ ';' _ dir, 1) %]

    I'm having a problem where if either query fails the result fail contains only a partial result.

    Is there a way to only create a result file if both queries are successful ensuring the result file contains both results?
     
  2. Support Денис

    Support Денис A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jun 12, 2017
    Messages:
    586
    Likes Received:
    185
    Hello. To solve your problem you can use two parsers and if the requests of both parsers are successful then write the result to a file.
    To check the success of a query, you can use the variable $code. For example,
    Code:
    [%
    IF p1.code == '200' && p2.code == '200';
    p1.data;
    END;
    %]
    
    Or you can check it again
    Code:
    IF p1.info.success && p2.info.success
     
    #2 Support Денис, Nov 6, 2017
    Last edited: Nov 6, 2017
  3. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Thanks!

    Is there not a way to make it work with a single parser?
     
  4. Support Денис

    Support Денис A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jun 12, 2017
    Messages:
    586
    Likes Received:
    185
    I think, specifically in this case, it will not work out
     

Share This Page