Reputation: 85
I'm looking to use preg_match to grab the followers value from a Vine profile page (Example: https://vine.co/u/906265806411804672). The only contents of the page source is the javascript that is loading the HTML:
window.App = require('appkit/app').create();
However, once the javascript has loaded the HTML, I can see the code:
<script id="metamorph-20-start" type="text/x-placeholder"></script> "73.1K"
When I use preg_match to find that 73.1 value:
$vineUrl = @file_get_contents('https://vine.co/u/906265806411804672');
preg_match('#<script id="metamorph-20-start" type="text/x-placeholder"></script> "(.*?)"#', $vineUrl, $followCount);
It doesn't search the rendered HTML, just the JS that loads the page in HTML. Is there any way to preg_match once the JS has loaded or a PHP alternative to sniff for the value once the page has fully rendered in HTML?
Upvotes: 0
Views: 164
Reputation: 5705
As I wrote already in the comments, JS is client side, PHP server side. So if you fetch the URL with PHP, the JS never gets executed.
Best way is to wait until Vine releases an API. So far, Vine doesn't have an official API. But there are some unofficial APIs you can use. However, keep in mind that they can break anytime and you're probably violating Vine terms of service.
Unofficial APIs I found are
For a description of the API endpoints (for the PHP and Python APIs) see https://github.com/starlock/vino/wiki/API-Reference
Upvotes: 1