1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Join our Telegram chat: https://t.me/a_parser_en
    Dismiss Notice

JavaScript error: TypeError

Discussion in 'A-Parser Support Forum' started by gruk, Aug 27, 2018.

  1. gruk

    gruk A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jan 29, 2016
    Messages:
    7
    Likes Received:
    2
    Hello,
    I'm trying to use the amazon scraper to retrieve product data but always get this error:

    JavaScript error: TypeError: Cannot read property 'push' of undefined at Parser.pushProduct


    using variables like $product.$i.title and the likes.

    What am i doing wrong?

    Thanks!
     
  2. Support Денис

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

    Joined:
    Jun 12, 2017
    Messages:
    586
    Likes Received:
    185
    Hello. Specify the version of the parser?
     
  3. gruk

    gruk A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jan 29, 2016
    Messages:
    7
    Likes Received:
    2
    It is 1.2.280
    I'm adding the variables to the field Results Format, using the default parser prest
     
  4. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,372
    Likes Received:
    2,102
    Please, show me your preset and the requests on which the error occurs.
     
  5. gruk

    gruk A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jan 29, 2016
    Messages:
    7
    Likes Received:
    2
    This is how it looks:

    1.png 2.png
     
  6. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,372
    Likes Received:
    2,102
    You have several errors at once:
    - if you specify a template in the General format of the result, you need to refer to the number of the parser you are using, for example $p1
    - for output of arrays, you need to use the .format method
    So the correct template will look like this:
    Code:
    $p1.products.format('$title\n')
    I recommend you read these articles in the Documentation:
    http://en.a-parser.com/wiki/results-representation/#arrays-of-results
    https://en.a-parser.com/wiki/result-format/
    http://en.a-parser.com/wiki/template-toolkit/#format-method-for-arrays
     
    gruk likes this.
  7. gruk

    gruk A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Jan 29, 2016
    Messages:
    7
    Likes Received:
    2
    Thanks a lot, i thought it must have been me. I looked through the wiki but could not find a solution. I have not been careful enough, so i thank you for your help!
     
    Forbidden and Support like this.

Share This Page