YouTube IFrame API: get video description - youtube-iframe-api

I need to fetch a video description (not a title) directly from a user's browser and the only legal that API provides is to call player.getVideoData() but it doesn't contain it.
I tried to use undocumented call to https://www.youtube.com/get_video_info?video_id={video_id} but it's blocked by CORS.
Also I found the API v3 videos/list call that looks like
https://www.googleapis.com/youtube/v3/videos?key=YOUR_API_KEY&part=snippet&id=VIDEO_ID
But as I understood it's intended to Server to Server calls and I don't want to put my API key here.
From what I googled it looks like previously the player.getVideoData() returned the description but now it seems broken.
So is any way to get the description directly from browser?

You can try read the description using document.querySelector- like:
document.querySelector("#description > yt-formatted-string").innerText
N.B. This querySelector worked for me even if YouTube website has in his URL parameter disable_polymer=11 or not.
or
document.querySelector("#eow-description").innerText
N.B: the last querySelector worked for me with old design. I recommend you use the first option, but have this querySelector just in case.
1 add disable_polymer=1 in the URL as a parameter for load YouTube's old design.

Related

web scraping from https://ngodarpan.gov.in/index.php/home/statewise_ngo/61/35

Is it possible for me to scrape the data from the pop up appears after clicking the link.the website is https://ngodarpan.gov.in/index.php/home/statewise_ngo/61/35
Of course it's possible, it's just a table with pagination.
But you'd better check the legal part before scraping a website, moreover on a governmental one.
Yes, you have to follow exactly what browser does. See network behaviour from your browser.
First, you have to send request to https://ngodarpan.gov.in/index.php/ajaxcontroller/get_csrf in order to get token like this :{"csrf_token":"0d1c59184c7df788dc4b8759f6da40c6"}
After, send another POST request to https://ngodarpan.gov.in/index.php/ajaxcontroller/show_ngo_info. As parameters you have to mention csrf_test_name which which is equals to csrf_token and id which is found from onclick attribute of each link.
You will get JSON as response and just to parse it as you need.

Wireshark showing post parameters in diffrent locations in follow TCP stream window

Im running some tests on a app and Ive stumbled upon an odd thing that happends when I sniff the traffic between me and the app server using wireshark:
In a scenario when Im making the post request through the app's html, it looks like that:
But when Im requesting the same thing using the chrome extension "postman", it looks like that:
why are the parameters are now shown at the top of the request? I mean, what changed here?
Im trying to find a clue why is it working in the first option and refuses to work on the second. thats why I need to investigate every little thing..
Edit:
I wrote a short html page to illustrate this and the second option happens here as well:
...
<form action="http://x.x.x.x/page.cgi?id=1726931735&host_name=blah" method="post">
....
postman will send an empty body by default, you need to enable the rows of key-value fields for them to be added to the request. postman does not read the form on the page, its parameters must be inserted into the plugin fields. Otherwise postman will send an empty request just like you see.
You need to enter the fields in the Body tab in postman:
It's very odd. The first one is correct. The second is using get semantics but doing a post with no content. I'd try something else instead of this chrome extension.

How to share only an image via Linkedin API

Using Linkedin via Buffer, I can share content with only an attached image. ie no accompanying comment, url, or any text. It is also possible via the web interface.
However, when using their share API, you are forced to include a URL and it displays with the content. Buffer must be using the API in some way, so how do you get around this?
I have been looking for the same solution.
How to get large LinkedIn Image Share Format
basically you just pass the image url in submitted-url field and don't pass submitted-image-url paramter in the json.
I was unable to find a this solution in google and in stackoverflow. I hope this help someone in the future.

API for word definitions

i'm trying to implement a little app which basically only hs a label, textbox and a button and when the user enters a word, i want to connect to some online api to retrieve the word's definition and display it in the label. is this possible? all i keep finding is api's related to other stuff on google/other se's. but i have seen this in practice before so i know they are out there, i just don't know where.
I suggest you try WordNet. It has got an API that you can use over the web.
Check it out here: http://wordnet.princeton.edu/wordnet/related-projects/#web
If you search more probably you will find, but let me give you a hint:
You can make a http web request to any website who handles word definitions. You can even search for "define: " + word in google and get the response.

Using ASP.Net, is there a programmatic way to take a screenshot of the browser content?

I have an ASP.Net application which as desired feature, users would like to be able to take a screenshot. While I know this can be simulated, it would be really great to have a way to take a URL (or the current rendered page), and turn it into an image which can be stored on the server.
Is this crazy? Is there a way to do it? If so, any references?
I can tell you right now that there is no way to do it from inside the browser, nor should there be. Imagine that your page embeds GMail in an iframe. You could then steal a screenshot of the person's GMail inbox!
This could be made safe by having the browser "black out" all iframes and embeds that would violate cross-domain restrictions.
You could certainly write an extension to do this, but be aware of the security considerations outlined above.
Update: You can use a canvas utility function to get a screenshot of a page on the same origin as your code. There's even a lib to allow you to do this: http://experiments.hertzen.com/jsfeedback/
You can find other possible answers here: Using HTML5/Canvas/JavaScript to take screenshots
Browsershots has an XML-RPC interface and available source code (in Python).
I used the free assembly UrlScreenshot.dll which you can download here.
Works nicely!
There is also WebSiteScreenShot but it's not free.
You could try a browser plugin like IE7 Pro for Internet Explorer which allows you to save a screenshot of the current site to a file on disk. I'm sure there is a comparable plugin for FireFox out there as well.
If you want to do something like you described. You need to call an external process that prints the IE output as described here.
Why don't you take another approach?
If you have the need that users can view the same content over again, then it sounds like that is a business requirement for your application, and so you should be building it into your application.
Structure the URL so that when the same user (assuming you have sessions and the application shows different things to different users) visits the same URL, they always see same thing. They can then bookmark the URL locally, or you can even have an application feature that saves it in a user profile.
Part of this would mean making "clean urls", eg, site.com/view/whatever-information-needed-here.
If you are doing time-based data, where it changes as it gets older, there are probably a couple possible approaches.
If your data is not changing on a regular basis, then you could make the "current" page always, eg, site.com/view/2008-10-20 (add hour/minute/second as appropriate).
If it is refreshing, and/or updating more regularly, have the "current" page as site.com/view .. but allow specifying the exact time afterwards. In this case, you'd have to have a "link to this page" type function, which would link to the permanent URL with the full date/time. Look to google maps for inspiration here-- if you scroll across a map, you can always click "link to here" and it will provide a link that includes the GPS coordinates, objects on the map, etc. In that case it's not a very friendly url but it does work quite well. :)

Resources