Python Requests – pass parameter via GET [closed]

Here’s the relevant code to perform a GET http call from the official documentation: import requests payload = {‘key1’: ‘value1’, ‘key2’: ‘value2’} r = requests.get(‘http://httpbin.org/get’, params=payload) In order to adapt it to your specific request: import requests payload = {‘q’: ‘food’} r = requests.get(‘http://httpbin.org/get’, params=payload) print (r.text) Here’s the obtained result if I run the … Read more

How to obtain the query string in a GET with Java HttpServer/HttpExchange?

The following: httpExchange.getRequestURI().getQuery() will return string in format similar to this: “field1=value1&field2=value2&field3=value3…” so you could simply parse string yourself, this is how function for parsing could look like: public Map<String, String> queryToMap(String query) { if(query == null) { return null; } Map<String, String> result = new HashMap<>(); for (String param : query.split(“&”)) { String[] entry … Read more

Remove parameters within nginx rewrite

Had a similar problem, after a lot of searching the answer presented itself in the rewrite docs. If you specify a ? at the end of a rewrite then Nginx will drop the original $args (arguments) So for your example, this would do the trick: location ^~ /mypage.php { rewrite ^/mypage.php$ http://www.example.com/mypage? permanent; }

Setting a custom userAgent in HTML or JavaScript

This is working for me. Object.defineProperty(navigator, ‘userAgent’, { get: function () { return ‘Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0)’; } }); It is an updated version of code4coffee’s answer as Object.prototype.__defineGetter__() is deprecated: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__