2012-02-04 117 views
1

正如标题所说,我需要发送HTTPS GET请求,然后以纯文本格式阅读JSON回复。我更喜欢python,但我也可以使用perl。HTTPS GET请求和读取JSON回复

编辑:好的,现在我可以从页面获取数据,但答复数据是SSL加密的,我将如何解密它?

+0

'urllib2'和'json'应该做的工作 – 2012-02-04 18:32:57

回答

1

的Python:

import json 
import urllib2 
data = json.loads(urllib2.urlopen(url).read()) 
+0

+1,但值得注意的是,对于'urllib2'来处理HTTPS请求,Python安装需要支持SSL。 – 2012-02-04 21:55:49

2

在Perl:

use JSON; # We will use this to decode the result 
use LWP::Simple; # We will use this to get the encoded data over HTTPS 
use Data::Dumper; # We will use this to display the result 

# Download the json data 
my $encoded_json = get("https://domain.com/url"); 

# Decode the json data 
my $result = decode_json($encoded_json); 

# Show the result in readable form 
print Dumper($result);