如何使用另一个网站用PHP进行查询?

时间:2016-11-19 10:26:21

标签: php html

我想用sci-hub.cc下载科学论文,但这是俄语,并不容易使用。 它有一个输入DOI或纸质链接的文本字段。

现在,我想创建一个网站,当用户插入纸质链接时,将此链接作为查询发送到sci-hub,然后下载。我怎么能在PHP中做到这一点?

非常感谢。

1 个答案:

答案 0 :(得分:0)

我不知道你的网页是如何工作的,但你要找的是" POST"请求。 下面的代码""如果您在页面上的字段中键入内容,则相同:

            <php
    $url = 'http://sci-hub.cc/';
    $data = ['Request'=>'TEXT FOR FIELD'];
    $options = array('http' => array(
                     'method'  => 'POST',
                     'content' => http_build_query($data),
                     'header'=>  "Content-Type:  application/x-www-form-urlencoded \r\n")
   );
       $context  = stream_context_create( $options );
       $result   = file_get_contents( $url, false, $context );
    ?>