溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

百度站內(nèi)搜索不支持https怎么辦

發(fā)布時(shí)間:2021-06-26 11:59:08 來(lái)源:億速云 閱讀:201 作者:小新 欄目:移動(dòng)開(kāi)發(fā)

這篇文章將為大家詳細(xì)講解有關(guān)百度站內(nèi)搜索不支持https怎么辦,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

最近手機(jī)端開(kāi)啟了https,為了綠鎖需要解決如下問(wèn)題:

1、圖片

2、js

3、css樣式

4、form查詢(xún)也要用https

第一種方法:通過(guò)js實(shí)現(xiàn)

但是最近做一個(gè)客戶(hù)需求的時(shí)候突然想到了一個(gè)曲線求國(guó)的辦法,反正我測(cè)試百度站內(nèi)搜索在https網(wǎng)站上是能用了,而且方法特別的暴力...

思路就是,做一個(gè)input,做一個(gè)button,在input里面輸入關(guān)鍵詞,用js控制點(diǎn)擊button直接打開(kāi)百度站內(nèi)搜索url+關(guān)鍵詞。反正能用了,我也不知道這么干對(duì)不對(duì)。。。

上代碼:

<input type="text" name="q" id="bdcsMain" value="百度站內(nèi)搜索" onfocus="if (value =='百度站內(nèi)搜索'){value =''}" onblur="if (value ==''){value='百度站內(nèi)搜索'}" >
 <button class="search-submit" id="btnPost" type="submit" onclick="window.open('http://zhannei.baidu.com/cse/search?s=1849457021752692468&entry=1&q='+document.getElementById('bdcsMain').value)">搜索</button>

只需要復(fù)制你百度站內(nèi)搜索結(jié)果頁(yè)的url替換掉上面代碼中的“http://zhannei.baidu.com/cse/search?s=1849457021752692468&entry=1&q=”就OK了。

第二種方法:通過(guò)php跳轉(zhuǎn)實(shí)現(xiàn)

搜索代碼不是js的

<form action="http://so.jb51.net/cse/search" method="get" target="_blank" class="bdcs-search-form" id="bdcs-search-form">
		<input name="s" value="10520733385329581432" type="hidden">
        <input name="entry" value="1" type="hidden">
        <input name="ie" value="gbk" type="hidden">
        <input name="nsid" value="3" type="hidden">
        <input name="ie" value="gbk" type="hidden">
<input type="text" placeholder="請(qǐng)輸入您感興趣的關(guān)鍵字" value="" id="search_txt1" maxlength="18" class="search_txt" name="q">
<input class="search_btn" value="搜 索" type="submit">
</form>

修改以后將action換成本地的php文件

<div class="search">
<form action="/do/search.php" method="get" target="_blank" class="bdcs-search-form" id="bdcs-search-form">
		<input name="s" value="10520733385329581432" type="hidden">
        <input name="entry" value="1" type="hidden">
        <input name="ie" value="gbk" type="hidden">
        <input name="nsid" value="3" type="hidden">
        <input name="ie" value="gbk" type="hidden">
<input type="text" placeholder="請(qǐng)輸入您感興趣的關(guān)鍵字" value="" id="search_txt1" maxlength="18" class="search_txt" name="q">
<input class="search_btn" value="搜 索" type="submit">
</form>
</div>

search.php如下

<?php
error_reporting(E_ALL & ~E_NOTICE);
$s=is_numeric($_GET['s'])?$_GET['s']:0;
$entry=$_GET['entry']?intval($_GET['entry']):0;
$nsid=$_GET['nsid']?intval($_GET['nsid']):0;
$ie=$_GET['ie']?substr($_GET['ie'],0,3):0;
$q=$_GET['q']?urlencode($_GET['q']):'';
$url_str="http://so.jb51.net/cse/search?s=$s&entry=$entry&ie=$ie&nsid=$nsid&ie=$ie&q=$q";
header("Location: $url_str");
?>

關(guān)于“百度站內(nèi)搜索不支持https怎么辦”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI