I want to use particular data of some website and show it my webpage.
I wanted to make an web article about the best Youtube Channels. Surely I have to write information about these channel.
For example, There is a youTube channel called "Example" and this channel has url like:
https://www.youtube.com/user/justforexample
I need amount of subscribers of it. In page source, it is inside tag:
<yt-formatted-string id="subscriber-count" class="style-scope ytd-c4-tabbed-header-renderer">4.5M subscribers</yt-formatted-string>
(actually i dont know if there is tag like that but tag maybe not only , it maybe <span> or <div>)
What I want is numbers. It should be in real time.
For instance, in 2020 this channel has 4.5M subscribers, after few years it turn out to be 5.8M.
Above was just example, it may not be only Youtube page, any website.
I know JS and jQuery and hope you help me :)
Thank you
Try sending an HTTP GET request to that url
Read about jQuery ajax function for more information: https://api.jquery.com/jquery.ajax/
Note that additional headers might be needed, try and analyze the response
i'm doing a little group chat that every message are stored into the database. When a message is store the page need to refresh. how can i do a thing like this ?
You can use Web Sockets to keep open a connection to the server. You can use the ratchet library: http://socketo.me/ Check the documentation to have a overview of this module.
Also, you can check this page to have an overview of this revolutionary system http://www.html5rocks.com/es/tutorials/websockets/basics/
EDIT:
However, you can use AJAX, but make it simple with JQuery. Don't complicate your code ;)
Ajax is simple to use with JQuery. Don't make a Text area becouse it is ugly. Make a in your document and other in an appart document and call it using:
$.get("theotherpage.html", function(data){
$("#localdiv").html(data);
});
Give a look at this page teaching you to use JQuery AJAX: http://www.w3schools.com/jquery/jquery_ajax_get_post.asp
You want to use AJAX. With AJAX you can refresh parts of the page, without refreshing the entire page.
We are creating a website based on images. Those images are uploaded on a facebook page too. I managed to get the albums, the images inside them and the likes that they have through Facebook Graph API. I'm using javascript to fetch all these urls and json to parse all the responses.
We could not found a way to get a like button or create one of our own that could manipulate the likes of each image and change them on facebook too.
I dig through Graph docs, i tried use the social plugin with urls like that https://graph.facebook.com/ but the results from json that fb graph gives ( witch are the true ones checked with the images ) are different from those in social plug in.
I'm not posting any code because i do not thing it is needed. But if someone need more details or code please feel free to ask.
I can use only Javascript for this task server side scripting not allowed.
Sorry for my enlgish, thanks in advance.
Well, if you have a look at the docs at https://developers.facebook.com/docs/plugins/like-button/ you could see that the URLs need to be some "public" URL, i.e. the "link" field of a photo object (as of https://developers.facebook.com/docs/graph-api/reference/photo).
I want to implement AJAX like facebook, so my sites can be really fast too. After weeks of research and also knowing about bigPipe (which is not ajax).
so the only thing left was how they are pulling other requests like going to page/profile, I opened up firebug and was just checking things there for what I get if I click on different profiles. But the problem is, firebug doen'tt record any such request and but still page gets loaded with AJAX and changes the HTML also, firebug does show change on html.
So I'm wondering, if they are using iframe to block firebug to see the request or what? Because I want to know how much data they pull on each request. Is it the complete page or only a part of page, because page layout changes as well, depending on the page it is (for example: groups, page, profile, ...).
I would be really grateful if a pro gives some feedback on this, because i cant find it anywhere for weeks.
The reason they use iframe, usually its security. iframes are like new tabs, there is no communication between your page and the iframe facebook page. The iframe has its own cookies and session, so really you need to think about it like another window rather than part of your own page (except for the obvious fact that the output is shown within your page).
That said - the developer mode in chrome does show you the communications to and from the iframe.
When I click on user's profile at facebook, then in Firebug I clearly see how request for data happens, and how div's content changing.
So, what is the question about?
After click on some user profile, Facebook does following GET request:
http://www.facebook.com/ajax/hovercard/user.php?id=100000655044XXX&__a=1
This request's response is a complex JS data, which contain all necessary information to build a new page. There is a array of profile's friends (with names, avatar thumbnails links, etc), array of the profile last entries (again, with thumbnails URLs, annotations, etc.).
There is no magic, no something like code hiding or obfuscation. =)
Looking at face book through google chromes inspector they use ajax to request files the give back javascript which is then used to make any changes to the page.
I don't know why/wether Facebook uses IFRAMEs to asynchroneously load data but I guess there is no special reason behind that. We used IFRAMEs too but now switched to XMLHttpRequest for our projects because it's more flexible. Perhaps the IFRAME method works better on (much) older browsers, but even IE6 supports XMLHttpRequest fine.
Anyway, I'm certain that there is no performance advantage when using IFRAMEs. If you need fast asynchroneous data loading to dynamically update your page, go with XMLHttpRequest since any modern browsers supports it and it's fast as HTTP can be.
If you know about bigPipe then you will be able to understand that,
As you have read about big pipe their response look like this :-
<script type="text/javascript"> bigpipe.onPageArrive({ 'css' : '', '__html' : ' ' }); </script>
So if they ajax then they will not able to use bigpipe, mean if they use ajax and one server they flush buffer, on client there will no effect of that, the ajax oncomplete only will call when complete data received and connection closed, In other words they will not able to use their one of the best page speed technique there,
but what if they use iframe for ajax,, this make point,, they can use their bigpipe in iframe and server will send data like this :-
<script type="text/javascript"> parent.bigpipe.onPageArrive({ 'some' : 'some' });
so server can flush buffer and as soon as buffer will clear, browser will get that, that was not possible in ajax case.
Important :-
They use iframe only when page url change, mean when a new page need to be downloaded that contains the pagelets, for other request like some popup box or notifications etc they simple send ajax request.
All informations are unofficial, Actually i was researching on that, so i found,
( I m not a native english speaker, sorry for spelling and grammer mistakes! )
when you click on different profile, facebook doesn't use ajax for loading the profile
you simple open a new link plain old html... but maybe I misunderstood you
I'm playing around with using some javascript to add extra functionality to a back button on my website. Right now I have a set of javascript that looks like this:
$(".back-link a").live("click", function(){
history.go(-1);
return false;
});
Now, it works great but I'm trying to make it as bulletproof as possible and one issue I foresee is that if someone lands on a project page and hasn't come to it via my home page then going back in their history one step will take them off my site. Obviously, this isn't what I want.
My guess is it would be a simple case of doing an if-statement but I'm not sure what or how to test for it. I suppose I could just test to make sure the base of the URL is my site but I'm not sure how.
Any tips or directions would be great.
No, it's not at simple as that. You can use the history collection to go back or forward, but you can't get the URLs in the history.
The only information that you can obtain about where the user comes from is the HTTP_REFERER string in the request header, but you have to use server side code to get that.