0

I've tried stripos, and regex...I found a beautiful article on why regex doesn't work with html but basically it's as the title says... I have an external site with a div that looks like this:

<div id="overlay" style="height: 3058px; display: block;"></div>

External site is being called like so:

$results = file_get_contents($url);

I tried using stripos for overlay but since there's multiple instances of overlay on the site, it's always returning true even when the div isn't there. I tried searching by "overlay" instead of just overlay but that didn't work either, nor did searching for

&quot;overlay&quot;

I did the same thing with preg_match

echo "Results:".preg_match('/overlay/', $results). ":End result.";
echo "Results:".preg_match('/"overlay"/', $results). ":End result.";
echo "Results:".preg_match('/&quot;overlay&quot;/', $results). ":End result.";

but I got the same issue

Ginzo Milani
  • 418
  • 1
  • 5
  • 18
  • if your intended "overlay" is loaded by javascript dynamically, you can't get it this way, and you should be using HTML parsers for this task instead – Kevin Apr 03 '15 at 04:11
  • How would I go about doing this? – Ginzo Milani Apr 03 '15 at 04:12
  • if its from an ajax, get the endpoint request, check the network tab, or use another way http://stackoverflow.com/questions/18539491/headless-browser-and-scraping-solutions – Kevin Apr 03 '15 at 04:20
  • It's not coming from Ajax, it's an overlay that appears if php has a form and sends true, atleast AFAIK.. – Ginzo Milani Apr 03 '15 at 04:30
  • if its pre rendered on the HTML markup on initial load, then there's a way to find it in PHP, but i wouldn't recommend regex solutions, if its rendered by javascript after the page has loaded, then its a different case. i'm not exactly sure what you're dealing with since the website link isn't attached in the question. but anyways, thats my thought – Kevin Apr 03 '15 at 04:34
  • I'm pretty sure it's on initial load and that it's prerendered, I want to share a link but the problem is the requirements to generate this div is moderator based so I can only really generate it while online but even though that's the case, I cannot actually modify or look at the code that was made. I'm using this div to check if my div is being generated successfully. – Ginzo Milani Apr 03 '15 at 05:57

0 Answers0