Z
Z
ZaurK2018-03-04 09:39:24
PHP
ZaurK, 2018-03-04 09:39:24

How to get src inside iframe tag?

Hello! Help solve the problem - there is an iframe on the page:

<div class="iframe-holder">
<iframe src="https://somesite.com/models/350795b06d684d3992a5efe5b3dd3c61/embed?api_version=1.0.0&amp;api_id=7376598513360515" width="876" height="400" id="api-frame" class="b_iframe" allowfullscreen="" mozallowfullscreen="true" webkitallowfullscreen="true" data-url="350795b06d684d3992a5efe5b3dd3c61"></iframe>
</div>

using phpquery i can get the html of the block wrapping this iframe with the .iframe-holder class, but the value of the link in src=' ' is empty. This is the problem - for some reason the value of the src attribute is empty, although the rest of the html is in place. How to get this url?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2018-03-04
@profesor08

let e  = document.querySelector(".iframe-holder iframe");

console.log(e.src);
console.log(e.getAttribute("src"));

M
Mikhail Sisin, 2018-03-05
@JabbaHotep

If the attribute value is empty, then it is filled using JS. This is easy to check if you have a Quick Javascript Switcher for your browser. Just disable JS and look at the DOM element you are interested in.
You need to study the mechanics of the page and find where the URL you need comes from. Or you can use a headless browser.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question