🏠 返回首頁 

百度云插件+APIKey

在百度云网盘的页面添加一个搜索框,调用搜索API搜索所有公开分享文件// To add a search frame that calls some api for searching some public shared files in BaiduYun cloud netdisk.

< Feedback on 百度云插件+APIKey

Review: Good - script works

§
Posted: 15-11-2015

soso现在有点点问题,增加了一个Bing搜索

function search(keyword, startIndex) {

…… case 'Bing': url = 'http://cn.bing.com/search?q=';//http://cn.bing.com/search?q=rk3368+site%3Apan.baidu.com&ie=utf-8 url = url + keyword + '+site%3Apan.baidu.com' + '&first=' + startIndex;//'&page=' + parseInt(startIndex / 10, 10) + 1; break; ……

……

function BingToData(html) { var data = { cursor: { estimatedR###ltCount: 0, r###ltCount: 0 }, r###lts: [] };

    //其中一条结果:
//<li class="b_algo"><h2>
//<a href="http://pan.baidu.com/wap/link?uk=2923110658&amp;shareid=3468815834&amp;third=3" target="_blank" h="ID=SERP,5101.1">YFK-<strong>RK3368</strong>-8189-20150821.rar_免费高速下载|百度云 网盘 ...</a></h2>
//<div class="b_caption"><p>文件名:YFK-<strong>RK3368</strong>-8189-20150821.rar 文件大小:497.55M 分享者:晨芯FAE 分享时间:2015-8-21 14:07 下载次数:5 ... 登录百度云客户端送2T空间 电脑版</p>
//<div class="b_attribution" u="0|5058|4835271386991248|8OMhcGIIj8GW08I41R5UoSyJpl2_5Pny"><cite><strong>pan.baidu.com</strong>/wap/link?uk=2923110658&amp;shareid=3468815834&amp;...</cite><span class="c_tlbxTrg">
//<span class="c_tlbxH" H="BASE:CACHEDPAGEDEFAULT" K="SERP,5102.1"></span></span></div></div></li>
//http://www.jb51.net/article/49083.htm在JS中解析HTML字符串示例代码:
var el = $( '<div></div>' );
el.html(html);
var b_r###lts = $("#b_r###lts", el);
var b_algo_Arry = $("li.b_algo", b_r###lts);
$.each(b_algo_Arry, function(index, val) {
var tempR###lt = {
unescapedUrl: "",
titleNoFormatting: "",
contentNoFormatting: ""
};
tempR###lt.unescapedUrl = $(val).find("h2 a").attr('href');
tempR###lt.titleNoFormatting = $(val).find("h2 a").text();
tempR###lt.contentNoFormatting = $(val).find('div.b_caption p').text();
data.r###lts.push(tempR###lt);
});
//搜索结果总数,超出当前一页的结果数时表示还有下一页。Bing的搜索结果总数需要从文字中提取:
//第一页时是这样的:<span class="sb_count"><i data-bm="116">14,900,000 条结果</i></span>
//第二页之后变成这样了:<span class="sb_count"><i data-bm="116">10 - 19 条结果(共 14,900,000 条)</i></span>
data.cursor.r###ltCount = 10000;//懒得去提取总数了,直接设为10000算了。
data.cursor.estimatedR###ltCount = data.cursor.r###ltCount;
return data;
}
§
Posted: 15-11-2015

另外,脚本中有这么一句:
totalPage = parseInt((totalR###lts - 1) / 10, 10) + 1 > 10 ? 10 : parseInt((totalR###lts - 1) / 10, 10) + 1; //坑比,google自定义搜索只提供最大10页(每页10条)
由于这句的问题,所有的搜索引擎搜得的结果最终都只能看前10页,11页以后无法查看。
将这句修改为:
totalPage = parseInt((totalR###lts - 1) / 10, 10) + 1;// > 10 ? 10 : parseInt((totalR###lts - 1) / 10, 10) + 1; //坑比,google自定义搜索只提供最大10页(每页10条)
那就可以了,soso、bing搜索的结果都可以查看11页及以后的了。谷歌什么的,反正都被河蟹了的,也懒得去##改hosts之类的了,搜百度网盘用这些完全可以了。

cinimaAuthor
§
Posted: 17-11-2015

666啊,等等我把总数提取搞定了更新下。估计要用正则。

cinimaAuthor
§
Posted: 18-11-2015

@wooddoor 搞定了 更新下看看正常不

§
Posted: 20-11-2015
@wooddoor 搞定了 更新下看看正常不

正常。

Post reply

Sign in to post a reply.