2013-04-18 55 views
0

我有我想下載和解析URL PHP/JavaScript內容編碼:如何下載HTML與使用wget或Perl

http://diana.cslab.ece.ntua.gr/micro-CDS/index.php?r=search/results_mature&mir=hsa-miR-3131&kwd=MIMAT0014996 

問題是,當我下載使用UNIX wget方式如下:

$ wget [the above url] 

它給我的內容與我在瀏覽器中看到的不同(即基因列表不存在)。

什麼是做編程的正確方法?

+1

這對我的作品。你在引用網址嗎? 「HTTP 996 ......」 – 2013-04-18 05:46:25

回答

1
#/usr/bin/perl 

use WWW::Mechanize; 
use strict; 
use warnings; 

my $url = "http://diana.cslab.ece.ntua.gr/micro-CDS/index.php?r=search/results_mature&mir=hsa-miR-3131&kwd=MIMAT0014996"; 

my $mech = WWW::Mechanize->new(); 
$mech->agent_alias("Windows IE 6"); 

$mech->get($url); 
#now you have access to the HTML code via $mech->content(); 

要處理的HTML代碼,我強烈建議只是測試到use HTML::TreeBuilder::XPath(或其他HTML解析模塊)

1

我使用PHP和拉帶的基因名單就好了

<?php 
echo file_get_contents('http://diana.cslab.ece.ntua.gr/micro-CDS/index.php?r=search/results_mature&mir=hsa-miR-3131&kwd=MIMAT0014996'); 
?> 

你有訪問PHP