0

I'm using Simple HTML DOM to scraping content to external page but sometimes the external page show the Age Verification and i can't scraping.

For scraping i have click on button to confirm my age, code:

<a class="btn_grey btn_medium" href="#" onclick="HideAgeGate()"><span>View page</span></a>

But how i can click or execute the function HideAgeGate() with Simple HTML DOM? or exist a other way?

Thomas Löffler
  • 5,922
  • 1
  • 14
  • 29
  • You can't do this with Simple HTML DOM. You need a headless client such as PhantomJS. Or, you could find out what request is made after clicking that (check the network log in your browser's developer tools), and just make that request directly. – Patrick Q Aug 06 '18 at 17:37
  • Thx for answer, the function create a cookie. I have a set cookie from HTML SIMPLE DOM? –  Aug 06 '18 at 17:56
  • _Can_ you? Yes, I think so. The `file_get_html()` function wraps PHP's [file_get_contents()](http://php.net/manual/en/function.file-get-contents.php), which allows passing a context. You can pass the context as the 3rd argument to [file_get_html()](https://github.com/sunra/php-simple-html-dom-parser/blob/master/Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php#L76). See [HERE](https://stackoverflow.com/questions/3431160/php-send-cookie-with-file-get-contents) for an example of creating the stream context. But, I'd probably just use [cURL](http://php.net/manual/en/book.curl.php). – Patrick Q Aug 06 '18 at 18:21

0 Answers0