| 10 | |
| 11 | |
| 12 | class XbRank(): |
| 13 | def __init__(self): |
| 14 | self.session = requests.session() |
| 15 | self.headers = { |
| 16 | 'accept-language': 'zh-CN,zh;q=0.9', |
| 17 | 'origin': 'https://newrank.cn', |
| 18 | 'referer': 'https://newrank.cn/public/info/search.html?value=pythonlx&isBind=false', |
| 19 | 'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"', |
| 20 | 'sec-ch-ua-mobile': '?0', |
| 21 | 'sec-fetch-dest': 'empty', |
| 22 | 'sec-fetch-mode': 'cors', |
| 23 | 'sec-fetch-site': 'same-origin', |
| 24 | 'cookie': 'acw_tc=781bad2216787867268296256e03a6a9c14e6a7c61d77b305955aa030954bb; Hm_lvt_a19fd7224d30e3c8a6558dcb38c4beed=1678786729; Hm_lpvt_a19fd7224d30e3c8a6558dcb38c4beed=1678786729; sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22186df7cd6291233-09a96708379fec-1e525634-2073600-186df7cd62a1ae3%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%22186df7cd6291233-09a96708379fec-1e525634-2073600-186df7cd62a1ae3%22%7D', |
| 25 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', |
| 26 | 'x-requested-with': 'XMLHttpRequest', |
| 27 | } |
| 28 | |
| 29 | def getxyz(self, path): |
| 30 | js = ''' |
| 31 | function nonce() { |
| 32 | for (var a = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"], b = 0; b < 500; b++) |
| 33 | for (var c = "", d = 0; d < 9; d++) { |
| 34 | var e = Math.floor(16 * Math.random()); |
| 35 | c += a[e] |
| 36 | } |
| 37 | return c |
| 38 | } |
| 39 | |
| 40 | function b(a) { |
| 41 | function b(a) { |
| 42 | return d(c(e(a))) |
| 43 | } |
| 44 | function c(a) { |
| 45 | return g(h(f(a), 8 * a.length)) |
| 46 | } |
| 47 | function d(a) { |
| 48 | for (var b, c = p ? "0123456789ABCDEF" : "0123456789abcdef", d = "", e = 0; e < a.length; e++) |
| 49 | b = a.charCodeAt(e), |
| 50 | d += c.charAt(b >>> 4 & 15) + c.charAt(15 & b); |
| 51 | return d |
| 52 | } |
| 53 | function e(a) { |
| 54 | for (var b, c, d = "", e = -1; ++e < a.length; ) |
| 55 | b = a.charCodeAt(e), |
| 56 | c = e + 1 < a.length ? a.charCodeAt(e + 1) : 0, |
| 57 | 55296 <= b && b <= 56319 && 56320 <= c && c <= 57343 && (b = 65536 + ((1023 & b) << 10) + (1023 & c), |
| 58 | e++), |
| 59 | b <= 127 ? d += String.fromCharCode(b) : b <= 2047 ? d += String.fromCharCode(192 | b >>> 6 & 31, 128 | 63 & b) : b <= 65535 ? d += String.fromCharCode(224 | b >>> 12 & 15, 128 | b >>> 6 & 63, 128 | 63 & b) : b <= 2097151 && (d += String.fromCharCode(240 | b >>> 18 & 7, 128 | b >>> 12 & 63, 128 | b >>> 6 & 63, 128 | 63 & b)); |
| 60 | return d |
| 61 | } |
| 62 | function f(a) { |
| 63 | for (var b = Array(a.length >> 2), c = 0; c < b.length; c++) |
| 64 | b[c] = 0; |
| 65 | for (var c = 0; c < 8 * a.length; c += 8) |
| 66 | b[c >> 5] |= (255 & a.charCodeAt(c / 8)) << c % 32; |
| 67 | return b |
| 68 | } |
| 69 | function g(a) { |