从需要 POST 数据的站点获取数据?

2022-01-20 00:00:00 post fetch php external

有一个非常简单的网站,其中只包含一些我想检索表格的元素.以前我使用 file_get_contents('http://www.example.com') 来达到这个目的,并通过 explode 和 str_replace 命令提取我需要的信息,效果很好.

There's a very simple website containing just a few elements of which I'd like to retrieve a table. Previously I've used file_get_contents('http://www.example.com') for this exact purpose and extracted the piece of information I needed through explode and str_replace commands, which worked fine.

但是,此网站需要 POST 数据才能显示我需要的表格.我只知道提交数据的选择框的名称和ID,以及我需要提交的选项值".

另一件事是,第二个选择框只在第一个被处理后出现,就像表格只在为两者选择一个选项后出现.

Another thing is that the second select box only appears once the first one has been dealt with, much like the table only appears once an option has been chosen for both.

我该如何取表?

提前致谢!

服务于餐桌的网站的抽象(和糟糕的)表示:

    <select id='select_box_1' name='first select box'>
      <option value='option1_1'>Thing one</option>
      <option value='option1_2'>Second thing</option>
      <option value='option1_3'>Thing number three</option>
    </select>

    NOTE: Selecting an option will spawn:

    <select id='select_box_2' name='second select box'>
      <option value='option2_1'>First thing</option>
      <option value='option2_2'>Second choice</option>
      <option value='option2_3'>The third option</option>
    </select>

    NOTE: Selecting an option will spawn the table I need.

推荐答案

试试 curl:

这里是一些例子

相关文章