试图从中提取JSON数据http://www.firstgiving.com 使用LWP::UserAgent
正如你们中的一些人可能已经听说的那样,目前有几个Subredits正在进行慈善活动,特别是r/无神论。为了帮助/鼓励募捐,我已经开始编写一个小的网络实用程序来提供关于这些捐赠的实时信息(基本上,将来自Reddit的数据与来自FirstGiving的数据进行混合)-你可以看到我到目前为止得到的信息-它只显示每个subreddit的总数和平均数字,这是非常初步的(也不漂亮。) 我想补充的一个功能是FirstGiving似乎没有提供的功能,即搜索或链接特定捐赠的功能。上周有很多帖子,人们试图提供捐赠匹配和类似的内容,但也有很多虚假/巨魔帖子,并且没有很好的方法来验证是否有人在“传递”(我们都知道截图很容易伪造。)我计划缓存FirstGiving的数据,以便有人可以链接到 检查了FirstGiving页面后,似乎有一个未记录的JSON API调用(在滚动到页面底部以显示更多捐赠时使用),该调用将以HTML表的形式返回捐赠金额、消息和昵称的列表。根据Opera Dragonfly的说法,当我在浏览器(Opera)中访问它时,它是这样的:试图从中提取JSON数据http://www.firstgiving.com 使用LWP::UserAgent,json,perl,lwp-useragent,Json,Perl,Lwp Useragent,正如你们中的一些人可能已经听说的那样,目前有几个Subredits正在进行慈善活动,特别是r/无神论。为了帮助/鼓励募捐,我已经开始编写一个小的网络实用程序来提供关于这些捐赠的实时信息(基本上,将来自Reddit的数据与来自FirstGiving的数据进行混合)-你可以看到我到目前为止得到的信息-它只显示每个subreddit的总数和平均数字,这是非常初步的(也不漂亮。) 我想补充的一个功能是FirstGiving似乎没有提供的功能,即搜索或链接特定捐赠的功能。上周有很多帖子,人们试图提供捐赠匹
URL: http://www.firstgiving.com/ProfileWebApi/Donations
Method: POST
Status: 200 OK
Duration: 1220 ms
请求详细信息
POST /ProfileWebApi/Donations HTTP/1.1
User-Agent: Opera/9.80 (Windows NT 6.1; U; Edition United Kingdom Local; en) Presto/2.10.229 Version/11.60
Host: www.firstgiving.com
Accept-Language: en-GB,en;q=0.9
Accept-Encoding: gzip, deflate
Referer: http://www.firstgiving.com/fundraiser/r-atheism/ratheism
Cookie: ASP.NET_SessionId=rmsl4b45jdxwykanpoqkb255
Connection: Keep-Alive
Content-Length: 111
Content-Type: application/json;
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
Content-Transfer-Encoding: binary
Request body
{"EventGivingGroupId":1476950,"TotalRaised":"190776.020000","PageIsExpired":false,"PageNumber":4,"PageSize":50}
Response details
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 62979
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 2.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Tue, 13 Dec 2011 19:13:28 GMT
身体
{"Data":"\u0009\u000d\u000a\u0009\u0009\u0009\u0009\u000d\u000a <table class=\"donationTable collapsed\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style='height:0px; overflow:hidden;' >\u000d\u000a <thead class=\"visuallyhidden\">\u000d\u000a\u0009\u0009 <tr>\u000d\u000a <th scope=\"col\">Comment<\/th>\u000d\u000a <th scope=\"col\" class=\"amount\">Donation<\/th>\u000d\u000a <\/tr>\u000d\u000a <\/thead>\u000d\u000a\u0009\u0009\u0009 \u000d\u000a <tr> \u000d\u000a <td class=\"comment\">\u000d\u000a \u000d\u000a <strong>Dear Regan Layman<\/strong>\u000d\u000a Happy holidays :)<br \/>\u000d\u000a \u000d\u000a <time datetime=\"2011-12-10T21:55:35.0000000\">\u000d\u000a 12\/10\/2011\u000d\u000a <\/time>\u000d\u000a \u000d\u000a <\/td>\u000d\u000a \u000d\u000a <td class=\"amount\">\u000d\u000a $20.00<sup style=\"font-size:10px;\" title=\"Offline donation\"><\/sup> \u000d\u000a \u000d\u000a <\/td>\u000d\u000a <\/tr>\u000d\u000a\u0009 \u000d\u000a <tr> \u000d\u000a <td class=\"comment\">\u000d\u000a \u000d\u000a <strong>Frodo Baggins<\/strong>\u000d\u000a Due to the fact that doctors heal people, not God!<br \/>\u000d\u000a \u000d\u000a <time datetime=\"2011-12-10T21:52:11.0000000\">\u000d\u000a 12\/10\/2011\u000d\u000a <\/time>\u000d\u000a \u000d\u000a <\/td>\u000d\u000a \u000d\u000a <td class=\"amount\">\u000d\u000a $4.64<sup style=\"font-size:10px;\" title=\"Offline donation\"><\/sup> \u000d\u000a \u000d\u000a <\/td>\u000d\u000a <\/tr>\u000d\u000a\u0009 \u000d\u000a
以下是输出:
$VAR1 = bless( {
'COOKIES' => {
'www.firstgiving.com' => {
'/' => {
'ASP.NET_SessionId' => [
0,
'yynhqi2udtz4y055fakdvjiu',
undef,
1,
undef,
undef,
1,
{
'HttpOnly' => undef
}
]
}
}
}
}, 'HTTP::Cookies' );
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2ferror%2f404">here</a>.</h2>
</body></html>
',
'_rc' => '302',
'_headers' => bless( {
'x-powered-by' => 'ASP.NET',
'client-response-num' => 1,
'location' => '/error/404',
'cache-control' => 'private',
'date' => 'Tue, 13 Dec 2011 19:43:56 GMT',
'client-peer' => '204.12.127.197:80',
'x-aspnet-version' => '2.0.50727',
'client-date' => 'Tue, 13 Dec 2011 19:36:45 GMT',
'x-aspnetmvc-version' => '2.0',
'content-type' => 'text/html; charset=utf-8',
'title' => 'Object moved',
'client-transfer-encoding' => [
'chunked'
],
'server' => 'Microsoft-IIS/7.5'
}, 'HTTP::Headers' ),
'_msg' => 'Found',
'_request' => bless( {
'_content' => '{"EventGivingGroupId":1476950,"TotalRaised":"190776.020000","PageIsExpired":true,"PageNumber":2,"PageSize":50}',
'_uri' => bless( do{\(my $o = 'http://www.firstgiving.com/ProfileWebApi/Donations')}, 'URI::http' ),
'_headers' => bless( {
'cookie2' => '$Version="1"',
'user-agent' => 'Opera/9.80 (Windows NT 6.1; U; Edition United Kingdom Local; en) Presto/2.10.229 Version/11.60',
'cookie' => 'ASP.NET_SessionId=yynhqi2udtz4y055fakdvjiu',
'x-requested-with' => 'XMLHttpRequest',
'accept-encoding' => 'gzip, deflate',
'content-transfer-encoding' => 'binary',
'content-type:' => 'application/json',
'referer' => 'http://www.firstgiving.com/fundraiser/r-atheism/ratheism'
}, 'HTTP::Headers' ),
'_method' => 'POST',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
}, 'HTTP::Request' )
}, 'HTTP::Response' );
$VAR1=祝福({
“COOKIES”=>{
“www.firstgiving.com”=>{
'/' => {
“ASP.NET_SessionId”=>[
0,
‘yynhqi2udtz4y055fakdvjiu’,
未定义,
1.
未定义,
未定义,
1.
{
“HttpOnly”=>未定义
}
]
}
}
}
}“HTTP::Cookies”);
$VAR1=祝福({
“_协议”=>“HTTP/1.1”,
“\u content'=>”对象已移动
对象移动到。
',
“_rc”=>“302”,
“_headers”=>祝福({
“x-powered-by'=>“ASP.NET”,
'客户端响应编号'=>1,
'位置'=>'/error/404',
“缓存控制”=>“专用”,
“日期”=>“2011年12月13日星期二19:43:56 GMT”,
'客户端对等'=>'204.12.127.197:80',
'x-aspnet-version'=>'2.0.50727',
“客户日期”=>“2011年12月13日星期二19:36:45 GMT”,
'x-aspnetmvc-version'=>'2.0',
'内容类型'=>'文本/html;字符集=utf-8',
'title'=>'Object moved',
“客户端传输编码”=>[
“大块的”
],
“服务器”=>“Microsoft IIS/7.5”
},“HTTP::Headers”),
“_msg”=>“已找到”,
“_请求”=>祝福({
“_content'=>”{“EventGivingGroupId”:1476950,“TotalRaised”:“190776.020000”,“PageIsExpired”:true,“PageNumber”:2,“PageSize”:50},
“_uri”=>祝福(做{\(我的$o=)http://www.firstgiving.com/ProfileWebApi/Donations“)},'URI::http'),
“_headers”=>祝福({
“cookie2'=>”$Version=“1”,
“用户代理”=>“Opera/9.80(Windows NT 6.1;U;英国本地版;en)Presto/2.10.229版本/11.60”,
“cookie”=>“ASP.NET_SessionId=yynhqi2udtz4y055fakdvjiu”,
“x-request-with'=>“XMLHttpRequest”,
“接受编码”=>“gzip,deflate”,
'内容传输编码'=>'二进制',
'内容类型:'=>'应用程序/json',
“referer'=>”http://www.firstgiving.com/fundraiser/r-atheism/ratheism'
},“HTTP::Headers”),
“_方法”=>“POST”,
$VAR1 = bless( {
'COOKIES' => {
'www.firstgiving.com' => {
'/' => {
'ASP.NET_SessionId' => [
0,
'yynhqi2udtz4y055fakdvjiu',
undef,
1,
undef,
undef,
1,
{
'HttpOnly' => undef
}
]
}
}
}
}, 'HTTP::Cookies' );
$VAR1 = bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2ferror%2f404">here</a>.</h2>
</body></html>
',
'_rc' => '302',
'_headers' => bless( {
'x-powered-by' => 'ASP.NET',
'client-response-num' => 1,
'location' => '/error/404',
'cache-control' => 'private',
'date' => 'Tue, 13 Dec 2011 19:43:56 GMT',
'client-peer' => '204.12.127.197:80',
'x-aspnet-version' => '2.0.50727',
'client-date' => 'Tue, 13 Dec 2011 19:36:45 GMT',
'x-aspnetmvc-version' => '2.0',
'content-type' => 'text/html; charset=utf-8',
'title' => 'Object moved',
'client-transfer-encoding' => [
'chunked'
],
'server' => 'Microsoft-IIS/7.5'
}, 'HTTP::Headers' ),
'_msg' => 'Found',
'_request' => bless( {
'_content' => '{"EventGivingGroupId":1476950,"TotalRaised":"190776.020000","PageIsExpired":true,"PageNumber":2,"PageSize":50}',
'_uri' => bless( do{\(my $o = 'http://www.firstgiving.com/ProfileWebApi/Donations')}, 'URI::http' ),
'_headers' => bless( {
'cookie2' => '$Version="1"',
'user-agent' => 'Opera/9.80 (Windows NT 6.1; U; Edition United Kingdom Local; en) Presto/2.10.229 Version/11.60',
'cookie' => 'ASP.NET_SessionId=yynhqi2udtz4y055fakdvjiu',
'x-requested-with' => 'XMLHttpRequest',
'accept-encoding' => 'gzip, deflate',
'content-transfer-encoding' => 'binary',
'content-type:' => 'application/json',
'referer' => 'http://www.firstgiving.com/fundraiser/r-atheism/ratheism'
}, 'HTTP::Headers' ),
'_method' => 'POST',
'_uri_canonical' => $VAR1->{'_request'}{'_uri'}
}, 'HTTP::Request' )
}, 'HTTP::Response' );
curl -vv -H 'Content-Type: application/json' \
-H 'Referer: http://www.firstgiving.com/fundraiser/r-atheism/ratheism' \
-H 'Cookie: ASP.NET_SessionId=svqlde45h0cvrv55hqvhwv55;' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Accept: application/json, text/javascript, */*; q=0.01' \
-d '{"EventGivingGroupId":1476950,"TotalRaised":"191532.480000","PageIsExpired":false,"PageNumber":2,"PageSize":50}' \
'http://www.firstgiving.com/ProfileWebApi/Donations'
curl -vv -H 'Content-Type: application/json' \
-H 'Referer: http://www.firstgiving.com/fundraiser/r-atheism/ratheism' \
-H 'Cookie: ASP.NET_SessionId=svqlde45h0cvrv55hqvhwv55;' \
-H 'X-Requested-With: XMLHttpRequest' \
-d '{"EventGivingGroupId":1476950,"TotalRaised":"191532.480000","PageIsExpired":false,"PageNumber":2,"PageSize":50}' \
'http://www.firstgiving.com/ProfileWebApi/Donations'