【问题标题】:How to download HTML encoded with PHP/JavaScript content using WGET or Perl如何使用 WGET 或 Perl 下载使用 PHP/JavaScript 内容编码的 HTML
【发布时间】:2013-04-11 02:15:20
【问题描述】:

我有一个要下载和解析的 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]

它给了我与我在浏览器上看到的不同的内容(即基因列表不存在)。

以编程方式执行此操作的正确方法是什么?

【问题讨论】:

  • 它对我有用。你引用网址吗? “http...996”

标签: php html perl unix wget


【解决方案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 解析模块)

【讨论】:

    【解决方案2】:

    我刚刚使用 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 的访问权限

    【讨论】:

      猜你喜欢
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多