Help With Google Parser Results Format

Discussion in 'A-Parser Support Forum' started by scrapefun, Oct 6, 2023.

  1. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    I have a preset that checks for multiple types of sites in Google search results that I need help with formatting the code properly.

    Currently I check for the presence of forums using this code:


    Code:
    FOREACH item IN p1.serp;
        IF tools.js.strIndexOf('forum', item.link);
            forumFound = 1;
            BREAK;
        END;
    
    END;
    I want to add multiple footprints instead of just checking for "forum" in the url. Here are a few examples:

    /threads/
    /board/
    index.php?topic=
    viewtopic.php
    board.

    How would I add these to the existing code above? Thanks.
     
  2. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,494
    Likes Received:
    2,147
    Most likely it is enough to list all the conditions using logical OR:
    Code:
    FOREACH item IN p1.serp;
        IF tools.js.strIndexOf('forum', item.link) || tools.js.strIndexOf('/threads/', item.link) || tools.js.strIndexOf('/board/', item.link) || tools.js.strIndexOf('index.php?topic=', item.link) || tools.js.strIndexOf('viewtopic.php', item.link) || tools.js.strIndexOf('board.', item.link);
            forumFound = 1;
            BREAK;
        END;
    
    END;
     
    scrapefun likes this.
  3. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Thanks! I would have never figured this out.
     

Share This Page