文件从iframe获取内容

I would like to get content of a iframe with id or class of that iframe.

$links = "https://www.amazon.co.uk/Book-Secret-Wisdom-Prophetic-Evolution/dp/599054314X/ref=pd_sbs_14_2/257-3608675-7951114?_encoding=UTF8&pd_rd_i=599054314X&pd_rd_r=f103ccc1-7985-11e9-987c-178a1a538946&pd_rd_w=E5xsZ&pd_rd_wg=206kw&pf_rd_p=18edf98b-139a-41ee-bb40-d725dd59d1d3&pf_rd_r=MV7NZ41V278ECZM1135G&psc=1&refRID=MV7NZ41V278ECZM1135G";

$res = @file_get_contents($links);

$dom = new DomDocument();

@$dom->loadHTML($res);

$xpath = new DOMXpath($dom);

I would like to get content by id:

$dom->getElementById('iframeContent');

However, it alway return a page, not content of that iframe.

Anyone meet that problem?, pls help.

Iframes don't have content (well, they might, but it is alternative content for when iframes are not supported by the client).

They have a src attribute containing a URL pointing at an external document.

You need to read the src attribute value, resolve it to an absolute URL (if it isn't one already), then make an HTTP request to it, parse that, and extract the data from it.