get

How to GET a URL with User-Agent and timeout through some Proxy in Ruby?

人走茶凉 提交于 2019-12-06 10:48:16
How do I get a URL if I need to get it through some proxy , it has to have a timeout of max n. seconds, and a User-Agent ? require 'nokogiri' require 'net/http' require 'rexml/document' def get_with_max_wait(param, proxy, timeout) url = "http://example.com/?p=#{param}" uri = URI.parse(url) proxy_uri = URI.parse(proxy) http = Net::HTTP.new(uri.host, 80, proxy_uri.host, proxy_uri.port) http.open_timeout = timeout http.read_timeout = timeout response = http.get(url) doc = Nokogiri.parse(response.body) doc.css(".css .goes .here")[0].content.strip end The code above gets a URL through a proxy with

Ajax request fails, can't see why

随声附和 提交于 2019-12-06 10:19:58
问题 I've created an API that returns data in json, and now I'm creating an app to test the API by receive the data and use it on the page. However, my ajax code (se below) fails by some reason, and the error says just "error" (Error: error). What can be wrong with the code? the code: $.ajaxSetup ({ url: "http://localhost:8000/products", // <--- returns json type: "GET", headers:{ "Accept":"application/json", "Content-type":"application/x-www-form-urlencoded" } }) $.ajax({ success: function(data){

Get value of a variable in another page using jquery

拈花ヽ惹草 提交于 2019-12-06 08:40:41
am really struck here. Actually the problem is, i have 2 web pages name as menu.html & index.html. in menu.html i have 3 buttons like "one,two,three", when i click any of a button it'll redirect to index.html. so, i wrote a common.js file for getting value of what button i clicked in menu.html. i have included common.js into both menu.html & index.html. common.js : var text=" "; $(document).ready(function() { $('input:button').click(function() { text = $(this).val(); alert(text); //here am getting correct values for a button like 'one,two or three' in menu.html page }); }); now i need to get

Passing multiple values for same GET variable in URL

微笑、不失礼 提交于 2019-12-06 08:29:34
I'm wondering if there is a cleaner way to pass multiple variables in a GET request than the following: http://www.mysite.com/somepage?tags[]=one&tags[]=two&tags[]=three I had thought about the following: http://www.mysite.com/somepage?tags=one,two,three Then using explode() to separate them. Wondered if anyone had seen or used a better solution though? Using explode() is only reliable if the values of each tag will never contain whatever string it is you're exploding by (in this case ","). I'd say it's safer to use tags[]=X&tags[]=Y . you can urlencode(json_encode(yourData)), then on the

How to send a GET request with a “/” in the query

只愿长相守 提交于 2019-12-06 08:12:23
I'm trying to write a test program to test my web service. I'm sending a JSON object to my web service via the GET method but it's not working. My test URL looks like this: http://testserver:8080/mydir/{"filename":"test.jpg", "Path":"test/2/2"} I'm thinking the "/" in the path are causing me problems since the program works fine once I remove them. Per REST how to pass values containing "/" as path parameter in the URI? , I've tried to use java.net.URLEncoder.encode but that isn't helping. Here's a snippet of my test program: // some code from main method <snip snip> String url = "http:/

Angular2 Error Handling Best Practice

…衆ロ難τιáo~ 提交于 2019-12-06 07:59:27
问题 I have a question about the best practice of Angular2 error handling. The is the code i use to catch an error: Getdata(data: object){ let body = JSON.stringify(data); let headers = new Headers({ 'Content-Type': 'application/json' }); return this.http.post('/getData', body) .map((res) => res.json()) .catch(this._errorHandler); } _errorHandler(error: Response){ console.log("Error Dataservice", error); return Observable.throw(error || "Server Error"); } Do i Need to make a Catch for each new

How to use Guzzle on Codeigniter?

三世轮回 提交于 2019-12-06 07:22:18
I am creating a web application on Codeigniter 3.2 which works with the Facebook Graph API. In order to make GET & POST HTTP requests, I need a curl library for Codeigniter. I have found Guzzle but I Don't know how to use Guzzle on Codeigniter. Check this link: https://github.com/rohitbh09/codeigniter-guzzle $this->load->library('guzzle'); # guzzle client define $client = new GuzzleHttp\Client(); #This url define speific Target for guzzle $url = 'http://www.google.com'; #guzzle try { # guzzle post request example with form parameter $response = $client->request( 'POST', $url, [ 'form_params' =

Getting Acces to Other Classes Variables

穿精又带淫゛_ 提交于 2019-12-06 07:20:18
I'm working on a pong game, since i'm new at programming, i don't know how to get acess to another class variable. I have seperate classes, green and blue paddles, a ball, and game1.cs. I control the ball movement with bool movingUp, movingLeft; It bounces off the borders of the screen, but i don't know how to make it work with the paddles. Basically, how do i check the position of the paddle, and make so when the ball touches the paddle, it bounces off? I mean, how to detect the collision? public class Ball { ParticleEngine particleEngine; GraphicsDeviceManager graphics; Texture2D texture;

TypeError: db.collection is not a function, CANNOT GET

本秂侑毒 提交于 2019-12-06 07:13:56
问题 i'm trying to get some data from the apiRoutes.get('/resources/productinfo/:name') and i have this error, i dont know whats going wrong... also the apiRoutes.get('/book/:title') doesnt seems to work! i dont know what am i doing wrong UPDATED: > TypeError: Cannot read property 'findOne' of undefined <br>    at Object.module.exports.findBookByTitle > (/home/themis/firstapp/api/config/database.js:22:26) <br>   >  at /home/themis/firstapp/api/server.js:109:22 <br>   >  at Layer.handle [as handle

How to get images from gallery and display them to the screen in android sdk

馋奶兔 提交于 2019-12-06 05:41:42
I would like to know how to get a pre-saved image from the gallery and then display it onto the screen. Any tutorials/helpful links and info would be appreciated. If there is anything you would like me to explain more, please ask. JohnNick Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, 1); This Intent used to pick the images from your SD cards and use onActivityResult() for get image and display the image in ImageView. public void onActivityResult(int requestCode, int resultCode, Intent data) { super