Chinaunix首页 | 论坛 | 博客
  • 博客访问: 584328
  • 博文数量: 69
  • 博客积分: 2204
  • 博客等级: 大尉
  • 技术积分: 808
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-11 22:37
个人简介

..微笑着看着杯中的花茶一片片撑开.. ..透明的花瓣里水破开的声音很轻微..

文章分类

全部博文(69)

文章存档

2018年(1)

2017年(2)

2016年(10)

2015年(8)

2014年(6)

2013年(6)

2012年(4)

2011年(8)

2010年(12)

2009年(12)

分类:

2011-04-01 17:24:17

因为要请求些数据,但是在构造POST请求时,发现平时的构造方法不起作用了。仔细查看了下代码,发现这个是multipart/form-data类型的。Google了一下,发现这个常来提交文件用。但是我所遇见的这个表单并不需要提交文件。翻了翻书,最后在CPAN上找到了解决的办法。

#!perl
#
#

use warnings;
use strict;
use LWP;
use HTTP::Request::Common;

my $url = "";

my $browser = LWP::UserAgent->new();

#这里用HTTP::Request::Common模块构建content内的内容;

my $request = POST(
                       $url,
                       Content_Type => 'form-data',
                       Content => [
                                     action =>'Search for all miRNAs predicted to target a Gene',
                                     clade => 'vertebrate',
                                     dataset => 'target predictions for all human microRNAs based on conservation in mammals (human, chimp, mouse, rat, dog)',
                                     name2 => 'hsa-let-7a',
                                     name1 => 'NM_014445'
                                  ]
                    );
#将构造好的内容通过LWP的request方法提交,获得返回的结果。

my $response = $browser->request($request);

print $response->content;


返回了正确结果。
阅读(1817) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~