Getting meta info from a webpage , given its url ? - metadata

I want meta-information of a webpage ,given its url . Is there any specific user-agent to put in get request headers , so that I get only required meta info not the whole html response ?
I know there is one way to get the whole html response and parse it ... but I am looking for more efficient solution(if any) ?
Thanks in advance :)

Sure! The most common command line tool and library for retrieving data with URLs is called cURL. You can get whichever part of the header that you want using this library.

Related

Docker REST API : Create Image issue : Need help for parameter fromSrc:

Hi Guys need your help.
I am creating an Image via docker REST API.
The link mentioned for parameter fromSrc following is the description :
fromSrc: Source to import. The value may be a URL from which the image can be retrieved or - to read the image from the request body. This parameter may only be used when importing an image.
if anyone can suggest the meaning of to read the image from the request body part and how we can test this
to read the image from the request body
means that you have to put your image as Json into the body of your request.
The URL, in this case, will look like this '.../images/create?fromSrc=-'
To test this, you can use Restlet client or Postman, which are chrome extensions that let you build a request with a body.

Redirection handling in ROKU

I am trying to call an API in ROKU player using bright script. But I a getting "response code -3". But when I am hitting that service on Web Browser it gives the xml in response. Actually there is a redirection in the API which I am using. As I know the redirection is not handled by the ROKU OS level. So How will I come out this situation.
Please help me and provide me any solution for that how can I handle the redirection in ROKU?
Thanks in advance.
The documentation at http://sdkdocs.roku.com/display/sdkdoc/roUrlEvent gives CURLE_URL_MALFORMAT as name for the -3 code you got from GetResponseCode() on the roUrlEvent. Try checking the string you get from GetFailureReason() on that same roUrlEvent, which should give a more detailed description of the problem.
Please check if you are missing any header in http request.
Check for accept header also.
Check this link how to make Get and Post request in Roku.
request = CreateObject("roUrlTransfer")
request.SetUrl("http://blog.roku.com/developer")
html = request.GetToString()

How to deal with this situation building a REST API?

I got this problem, I have built a rest api and I don't know how to deal with this:
When the javascript client (Marionette.js) is in charge of making the views, I don't have problems, because as it is known, it just requests an url (e.g. example.com/user/37), the server retrieves a json with {id:'37', name:'Peter', age:'24'} (there is one controller class named User) and Marionette shows that data in the view. But if the user enter to example.com/user/37 by the browser it will show just {id:'37', name:'Peter', age:'24'} without any view. What can I do if I want to see the same view in both cases?
If you're trying to serve up HTML or JSON from the same endpoint then your server should be making that decision based on the request's Accept header. If the request's Accept header is application/json then your server should return just the JSON ortherwise return the HTML.
You can see that SoundCloud uses the same technique for returning XML or JSON from their API:
Resources are returned as XML by default, or JSON if a .json extension is appended to the resource URI. We encourage you to use JSON. You can also send an appropriate Accept header specifying the format you would like. For example, a request with the header Accept: application/json will return resources represented as a JSON document.
What you are trying to do is pratically impossible.
why ?
When your first enter the url example.com it's the server that responds with all the artifacts that compose your application (html, js, css ...) and the browser display it.
Now, when you enter ther url example.com/user/37 the server only sends the JSON data without any html, js or css, so the browser display the raw data he received.
What you are trying to do is to force the server to give two responses (JSON or html/js/css) depending on the user request.
You can do it, but it would be so complicated that's not worth the efforts.

Sending a URL/filePath in Resteasy request

I want to send path of a file alongwith some Strings.
After spending some time I was unable to find anything that can help. Could anyone suggest any link on how to do this on server side
You can use any of the following methods to submit a file path and some strings to the server:
Submit a Form with the file path and strings.
Encode the file path and send it as a query parameter in the URL along with the strings.
Create a message body containing the file path and other strings you want to send and submit it via a POST call.
Send the file path and strings in custom http headers.
Take a look at the Resteasy documentation here: http://docs.jboss.org/resteasy/docs/3.0.4.Final/userguide/html_single/
Pay special attention to the sections that talk about using the #Form, #FormParam, #QueryParam, and #POST annotations.

jMeter signing URL and hash

We are working on a time critical task and are required to write performance script for a REST WS using jMeter.
The REST API takes an auth header. This auth header has:
A signed URL (of the REST API itself).
A hash of everything sent in POST body.
We want a jMeter script so that it can:
Read the contents of the POST body from say an excel sheet or from a java method etc. as the content of post body has to change per login.
Create the hash of POST body everytime the content of body changes and use this hash in the auth header.
Sign the URL and use it in auth header.
My questions are:
Is all the above possible to achieve? This is the minimum i want to know so that I know if I have to spend any more time on this.
What is the best way to do this?
I am assuming that the content of POST body and auth header both can be dynamic. Is this correct? If not, we cannot write this script at all.
The only jMeter i know is what is here in the comment. It would be impossible to get all my answers in the given time.
Any answers, help, pointers would be helpful.
Appreciate you reading this - thanks in advance.
Yes, possible. We have done similar things.
Two possible options are:
use a beanshell pre-processor
use a custom function
We opted for the latter as it used memory better
and 3. Yes, you can pass in vars to make each request different. One way to source data is using a CSV Data Config control.