【问题标题】:How to format curl --data argument to match jQuery ajax request?如何格式化 curl --data 参数以匹配 jQuery ajax 请求?
【发布时间】:2018-05-11 08:01:50
【问题描述】:

网站具有以下用于检索信息的功能:

function show_best_matches(sequence_id, version_id) {
    jQuery.ajax({
        type: "GET",
        url: 'https://unite.ut.ee/show_best_matches.php',
        data:{
            sequence_id: sequence_id,
            version_id: version_id,
        },
        success:function(html) {
            document.getElementById("best_matches").innerHTML = html;
        }
    });
}

我想使用 curl 来检索这些数据。我有所有正确的输入(序列 ID 和版本 ID),但我认为我没有将 --data 参数格式化为正确 curl。这是我尝试过的(基于其他 stackoverflow 搜索):

curl -d "sequence_id=56719" -d "version_id=7" -X GET --url https://unite.ut.ee/show_best_matches.php

感谢您的帮助。如果 curl 不是在这里使用的正确工具,我愿意接受建议。

【问题讨论】:

  • 经过更多搜索后,我尝试了{"sequence_id": "56719", "version_id": "7"},但也没有成功。

标签: jquery ajax curl web-scraping


【解决方案1】:

答案是这样的:

https://unite.ut.ee/show_best_matches.php?sequence_id=56719&version_id=7

事实证明,您没有将 curl 的 --data 部分与 GET 一起使用,您只需将参数添加到 URL 的末尾。第一个 arg 以 ? 开头,其余 arg 用 & 分隔。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-20
  • 1970-01-01
  • 1970-01-01
  • 2018-02-16
  • 1970-01-01
  • 1970-01-01
  • 2010-11-25
相关资源
最近更新 更多