Server side screenshot with puppeteer? - puppeteer

Im trying to build an api with and endpoint that renders some html but no reponse, it only save an screenshot of that html in the server.
After doing some research i found something similar could be done with puppeteer or another headless browser, but i have a problem.
The structure that i nedd is.
Client -> API ->(Provide the content to render) Response -> Puppeteer -> Save image.
As you can see, i want puppeteer to get the response directly from the api.
The problem is every example needs an intermediary API that serves that html so you can make request to that secondary api with puppeteer.
Client -> API ->(Provide url) Puppeteer -> Secondary API -> Response -> Puppeteer -> Save image
Is there any way to avoid the second API.
I want to pass the data directly to puppeteer, not an url to make another request.
Thank you

Related

How to find parameters (variables) in a web site by using google chrome for JMeter

I just started to use JMeter. I want to know how can I see the variables at google chrome. I tried so many ways and I watched lots of videos but there are no answers. Every video says that; you can find it in the network page from console. But on the website which im looking for variables, I just can see JavaScript code token. There is no token as variable. Is there a way to import it into JMeter or is there other way to find variables in google chrome. To put it in a nutshell, I'm working on a project. I want to load test for a website but I got problems with POST request. I cannot login the threads because of cannot find the variables. I need help !! :(
This is what I am trying to reach with screenShot...
This is my chrome's screenShot
I'm just tryna get the parameters like first pic.
There are 2 possibilities:
The "variable" comes in the response, take a closer look at:
response URL as it may be a part of the URL after redirection
response headers (can be observed in the "Network" tab of the developer tools)
response body, you can view page source
The variable gets "calculated" in the browser using JavaScript code. If this is the case you should find the relevant JavaScript function and implement it using JMeter's JSR223 Test Elements
You can also try recording your test scenario using BlazeMeter Proxy Recorder, it's capable of exporting recorded scripts in "SmartJMX" mode with automatic detection and correlation of the dynamic parameters. In case #2 it will not help, but if the variable comes with the response most probably it will be able to detect it. More information: How to Cut Your JMeter Scripting Time by 80%

How to access XHR requests using Chrome DevTools Protocol?

I want to access live XHR request data in Chrome programatically. (I can't just connect to the website using a script, it must go through Chrome)
So far, I've found the easiest way to do this is to launch Chrome with remote-debugging turned on. And then use Chrome DevTools to get the data:
import PyChromeDevTools
chrome = PyChromeDevTools.ChromeInterface()
chrome.Network.enable()
chrome.Page.enable()
chrome.Page.navigate(url='http://example.com/')
The Chrome DevTools protocol guide is here:
https://chromedevtools.github.io/devtools-protocol/
But I don't know how to actually access the live XHR requests.
Here's the data shown in the Chrome DevTools UI:
The connect requests contain everything I need in the response body. I simply need access to them live (as they continue to stream in).
I just want to access this data using DevTools-protocol so I can further process it.
Any ideas how?

Access Google Maps API json in browser

Silly question I am sure.
But how can I access this for simple testing but also whilst inside a phonegap which has no URL directly through the browser:
https://maps.googleapis.com/maps/api/geocode/json?address=122+flinders+st,+darlinghurst,+nsw,+australia&sensor=false&key=API_KEY
I have of course changed the API key which is a browser key. I have also changed my Referers: * So everything should be allowed.
Try this. It's a very simple phonegap maps api example.
One option is to use the Advanced REST Client Plugin which is free and you can install it on your chrome browser. This plugin opens directly in browser tab and you can set the request in a huge text box, set the type of request (GET, PUT, POST, DELETE etc) and also the parameters if required. You can see the results in below when you hit submit.
This Plugin is exclusively made for testing purposes relating to matter like sending a request to an API and then getting the results back from it in either JSON or XML format.
Click this link in order to install it in your Chrome Browser.
Hope that Helps!!

Open window and send POST data

I'm building an Add-on that needs to open a window and send some for data (via POST) to a remote server. I can do either of those items fine - UrlFetchApp() for sending the data, and an anchor tag to open a new window, but I couldn't find a way to do both of them together.
Basically I need to send the user to another website temporarily and provide that website with some data entered within the Add-on. I tried doing this with pure javascript, but the window.open() method is not available within the GAS sandbox.
Thanks!
Its not possible in apps script (and not possible in javascript either).
What you need is to open the external site with anchor & needed parameters (post data) in the url itself. Your external url in its javascript must convert the params to a Post (or handle it directly in its server's Get)
Also, if the external page is for doing some authentication with callback (like oauth flow) apps script now support such 'oauth callbacks'

Google Chrome Extension for interacting with a web application

hope somebody understand and can maybe explain me my idea.
My Goal:
I would like that the user can use my web application, but the requests for parsing urls, etc will not run on my server, but
are processed on the client side via the browser.
My theoretical example:
There is a web application the user need to login.
If the user is logged in, he can paste ten urls into a textinput box and than push a button.
Then a ajax request is made to the server and the urls are parsed and the site informations from the parsed urls comes back as json to display it in the frontend.
Ok now my real question.
Is it possible to create a Google Chrome Extension that catches the Post request from the textarea, and send the urls to the
background.js. than the background.js should request this urls via javascript xmlhttprequest to bypass the cross-orgin restriction.