0

I am trying to parse links from this page.

I use this code:

$link = 'https://ws-na.assoc-amazon.com/widgets/cm?t=websitcom05-20&o=1&p=26&l=ur1&category=primeent&banner=1XSEYPQA2R6RS2D2B802&f=ifr';
$pageContent = file_get_contents($link);
$html = str_get_html($pageContent);

$body = $html->find('body', 0, true);

foreach ($body->find('area') as $area)
{
    echo $area->href;
}

The output is http://rcm-na.amazon-adsystem.com/e/cm/privacy-policy.html?o=1 https://www.amazon.com

The second link is truncated. Please help me out to get the full link from the page.

I need to have this output: https://www.amazon.com/gp/video/offers/ref=dvm_us_dd_as_evgrn?ie=UTF8&linkCode=ur1&redirectToAsin=B01EN8ZQKS&tag=INSERTSTOREID&tag=websitcom05-20

Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69

1 Answers1

0

You appear to be using "PHP Simple HTML DOM Parser" (found at: http://simplehtmldom.sourceforge.net/)

not the full fat "DOMDocument" so it might have limits on what it can process on links.

for DOMDocument there is a question found here: Using domDocument, and parsing info, I would like to get the 'href' contents of an 'a' tag

that covers getting the href

IcePops
  • 11
  • 4