in the app's main window there's a webbrowser control with a page that requires authentication already logged on. is it possible to use the control (header, cookies...) to make a http request so i can update some other components without navigating directly from the webbrowser?
You could make an AJAXy request.
Related
I want to send some HTTP POST requests to a website. There's no problem with doing it by my browser, since I'm logged in and I have my authenticated session.
I don't know how to make POST requests by Python while using that authenticated session (so importing data from the browser), and I don't even know if it's possibile, so I thought that I could trigger these POST requests in browser from the Python script.
I know there exists a library called "webbrowser" that allows to make requests by opening new tabs in browser. My problem is that I need a POST request, not a GET one.
So I ask you for 2 suggestions: is there a way to import authenticated session such that Pyhon can make requests for websites that require auth?
If not, is there a way of doing something like this:
webbrowser.open(url, new=0)
but with POST requests?
Thanks!
I agree with Mr. C, but alternatively...
Checkout Selenium. You can't make a direct POST request, but you can do anything that you would usually do as a normal user.
Check out the requests library. Seems like you need more functionality than the webbrowser module provides.
Given that we can do routing with Express on the server, why do need a client side router?
What are the benefits, and is it only significant to SPA?
Client side routing is required to keep your application in sync with the browser URL.
It is mainly useful for Single Page Applications where the backend will be used for RESTful API calls via XHR or AJAX calls.
Being a SPA uses can book mark your URL and when they hit the URL again , your application should load that page with the data and its state.
The main difference between Server side routing and client side routing:
1. In Server Side routing you download(serve) the entire page.
2. In client Side routing along with the entire page, you can serve a specific portion of a page, reuse the DOM, manually manage the URL and history states. eg.
www.something.com/page1/tab1 will show tab1 in the UI
www.something.com/page1.tab2 will show tab2 in the UI
In this way the url can get more complex and you can have sub-routes with states.
Those who need a client-side router, need it for state management. Say you have server-rendered pages, but with some client-side widgets - e.g. a calendar, set of filters or collapsed or open sidebar. Router helps you initialize these components of the page in the exact state you want them. Granted, you could do most of it and all of the use cases I've named on the server, too. But it's usually a lot easier to handle these on the client. You might render it faster on the server, but sometimes, especially when doing partial page updates, it's cheaper and faster to handle that client-side.
can any explain me about how the server responds if we click the button in browser using PHP script then which situation we use JAVASCRIPT and which situation we have to use PHP .
If you're asking about how it works, I'll suggest to google about HTTP protocol, POST and GET methods.
Usually, you use JavaScript to send request to a server when you want it to be AJAX, ie when you want to send request to server and receive response without reloading page. And you use PHP when you have form in your HTML (like login or registration form), and you send it to server in one request to go to another page
If I write a chrome extension, it normally consist of multiple parts:
One is the devtools page which is a normal HTML page with origin set to
"chrome-extension://<guid>/filename". On that page I can use
the Dropbox API to get user confirmation via HTML popup and then use
the saved auth info and do all work via the Dropbox javascript library.
Another part of extension is the content script which is executed
in the context of specified third-party web pages ("injected") and have
origin cookies and web storage shared with them.
Is it possible to also use the Dropbox JavaScript library in that content script?
I can't call authenticate in interactive mode since it will re-ask for confirmation for each different webpage I'm injected into. And calling authenticate without interactive will fail since the content script doesn't share the origin, cookies and web storage with the devtools extension page :(. Maybe there's some way to "pass" the Dropbox auth info from the part of the extension that offers GUI and where user successfully confirms dropbox usage to the parts of the extension that are GUI-less, like content script or background page?
I have managed to get Facebook working from code injected into a web app via a content script. I suspect there are multiple ways, but what I did was take advantage of the chrome.identity API to do the OAuth work for me, specifically the launchWebAuthFlow().
This can only be done in the background page (in my case an event page), but I send messages to the event page which replies with the access_token, which can then be used in URLs in the same was as the 'web' technique - i.e. in HTTP requests with XHR.
You can send/receive messages via the content script (using events on document), but I decided to do it directly using "external" messages with the chrome.runtime.sendMessage() API in the web app context, and chrome.runtime.onMessageExternal() in the background script. This requires adding "matches" for the URLs you're injecting code into in an "externally_connectable" section of the manifest.json.
I believe this can be adapted to make it work with Dropbox.
I want to call a webservice using http post/get in my html webpage using javascript.
Link is shown below,
http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=Nepal
It is a cross domian call and i want to call it directly on my webpage,
I want to access the data of this link using javascript.
Thanks in advance.
If you don't control that domain, and I'm guessing you don't. You will need to create a web application that can act as a proxy and call this xml code server side. (As there are no cross domain restrictions)
You can then call your own web application via an AJAX request on the frontend.