Get Full Redirect Chain....

Discussion in 'A-Parser Support Forum' started by scrapefun, May 10, 2024.

  1. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    I found in the documentation how to get a single hop of a redirect using this:
    $response.Redirects.0.URI;$response.URI

    How would I get the full, redirect chain of a link with multiple redirects? I assume I need to format using an array but not sure the correct format.

    As an example this link has 4 redirects and I want to be able to get the full list:
    https://order-nowx.com/AlphaTonic_DISCOUNT
     
    #1 scrapefun, May 10, 2024
    Last edited by a moderator: May 10, 2024
  2. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    I came up with a solution but it seems a bit off?

    [% FOREACH response.Redirects -%][$URI,$response.URI],[% END %]

    This seems to repeat some urls instead of having just a clean redirect chain of one hop to the next.
     
    #2 scrapefun, May 10, 2024
    Last edited: May 10, 2024
  3. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,544
    Likes Received:
    2,163
    Code:
    $response.Redirects.format('$URI\n--> ')$response.URI
    [​IMG]
     
    scrapefun likes this.
  4. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Works great! Thanks.
     
    Support likes this.

Share This Page