Assign Value of "1" or "0" To Output Variable?

Discussion in 'A-Parser Support Forum' started by scrapefun, May 30, 2015.

  1. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    When scraping Google, I am creating some regex to check to see if certain div elements appear on the search results page.

    I don't actually want to extract the div element but just want to know if it exists or not on the page.

    How I can I assign a value of "1" if it exists or "0" if it doesn't to the result file like the $misspell variable does?
     
  2. Forbidden

    Forbidden Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 9, 2013
    Messages:
    3,339
    Likes Received:
    1,799
    Just test variable compared to 'none':
    [​IMG]
     
    Support likes this.
  3. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

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

    I'm having trouble putting everything together. Here is what I have:

    parsersettings.png

    I'm sure I'm missing something very simple and more than likely bungled the regex :)

    Basically, I want to check the search result page for the exact text I put in parenthesis in the regex field (I've tried it without the parenthesis too) and if it exists display a 1 and if not display 0.

    Of the keywords in the queries box only the results for "how to kill fruit flies" should display a "1" and the others should display a "0" but any keyword I use displays a 1.
     

    Attached Files:

  4. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Looks like the data I'm trying to find is requires javascript to be rendered and I see in debug mode that the javascript is not rendered. There is no way to search the full source code of s SERP page?
     
  5. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,572
    Likes Received:
    2,170
    For work with raw data in this parser it is necessary through to switch on the option Raw data results
    [​IMG]
    Also instead of answer = 'none' need to be written check.0.answer == '' to Result format, as there is an address not to a variable, and to value in the array
    [​IMG]
    No, the way to search the full source code of a SERP page doesn't exist.
     

Share This Page