문제

So here is my problem,

I am trying to retrieve a value from a website and copy it to a database on my webserver every 15 or 30 minutes. I want to do this because the value is the number of users connected to the website and I want to see when is the best time to post content in order to get the most views possible.

The problem here is that the value in question is loaded by Jquery and therefor I'm unable to user DOMDocuments to get the value since it isn't initially loaded with the page itself

I also tried to use Jquery to retrieve the page in order to get the value but it didn't load the value in question.

Then I searched for the script that filled in the number of users and found the post Jquery function that loads the value but haven't been able to retrieve it. I then discovered that the external server must be configure in order to accept cross browsing !

Now I don't really know what to try. Does any one have an idea what I could try next ?

Here is the link to the webpage containing the number of users onling bit.ly/1ljFkhh ( at the bottom of the list on the left side)

도움이 되었습니까?

해결책 2

$source = file_get_contents('http://www.newschoolers.com/post/chrome.php?a=online');

echo count(json_decode($source)->ONLINE);

다른 팁

Yes as you have discovered you cannot (from JavaScript) make requests across domains if the owner of that domain has not enabled their server to do so. You will need to do this from a server-side language. If you, for some reason need this value on your client you can make an AJAX call from your page to your server page that retrieves this value.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top