簡體   English   中英

如何使用WGET或Perl下載使用PHP / JavaScript內容編碼的HTML

[英]How to download HTML encoded with PHP/JavaScript content using WGET or Perl

我有一個我想下載和解析的URL:

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]

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

以編程方式執行此操作的正確方法是什么?

我剛剛使用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嗎?

#/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解析模塊)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM