MCPcopy
hub / github.com/gaotianliuyun/gao / searchParse

Function searchParse

lib/drpy.js:1645–1824  ·  view source on GitHub ↗

* 搜索列表数据解析 * @param searchObj * @returns {string}

(searchObj)

Source from the content-addressed store, hash-verified

1643 * @returns {string}
1644 */
1645function searchParse(searchObj) {
1646 fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
1647 let d = [];
1648 if(!searchObj.searchUrl){
1649 return '{}'
1650 }
1651 let p = searchObj.搜索==='*'&&rule.一级 ? rule.一级 : searchObj.搜索;
1652 if(!p||typeof(p)!=='string'){
1653 return '{}'
1654 }
1655 p = p.trim();
1656 let pp = rule.一级.split(';');
1657 let url = searchObj.searchUrl.replaceAll('**', searchObj.wd);
1658 if(searchObj.pg === 1 && url.includes('[')&&url.includes(']')&&!url.includes('#')){
1659 url = url.split('[')[1].split(']')[0];
1660 }else if(searchObj.pg > 1 && url.includes('[')&&url.includes(']')&&!url.includes('#')){
1661 url = url.split('[')[0];
1662 }
1663 if(/fypage/.test(url)){
1664 if(url.includes('(')&&url.includes(')')){
1665 let url_rep = url.match(/.*?\((.*)\)/)[1];
1666 // console.log(url_rep);
1667 let cnt_page = url_rep.replaceAll('fypage', searchObj.pg);
1668 // console.log(cnt_page);
1669 let cnt_pg = eval(cnt_page);
1670 // console.log(cnt_pg);
1671 url = url.replaceAll(url_rep,cnt_pg).replaceAll('(','').replaceAll(')','');
1672 }else{
1673 url = url.replaceAll('fypage',searchObj.pg);
1674 }
1675 }
1676
1677 MY_URL = url;
1678 console.log(MY_URL);
1679 // log(searchObj.搜索);
1680 // setItem('MY_URL',MY_URL);
1681 if(p.startsWith('js:')){
1682 const TYPE = 'search';
1683 const MY_PAGE = searchObj.pg;
1684 const KEY = searchObj.wd;
1685 var input = MY_URL;
1686 var detailUrl = rule.detailUrl||'';
1687 eval(p.trim().replace('js:',''));
1688 d = VODS;
1689 }else{
1690 p = p.split(';');
1691 if (p.length < 5) {
1692 return '{}'
1693 }
1694 let p0 = getPP(p,0,pp,0);
1695 let _ps = parseTags.getParse(p0);
1696 _pdfa = _ps.pdfa;
1697 _pdfh = _ps.pdfh;
1698 _pd = _ps.pd;
1699 let is_json = p0.startsWith('json:');
1700 p0 = p0.replace(/^(jsp:|json:|jq:)/,'');
1701 // print('1381 p0:'+p0);
1702 try {

Callers 1

searchFunction · 0.70

Calls 8

pushMethod · 0.80
getPPFunction · 0.70
printFunction · 0.70
postFunction · 0.70
getHtmlFunction · 0.70
verifyCodeFunction · 0.70
setItemFunction · 0.70
dealJsonFunction · 0.70

Tested by

no test coverage detected