鱼C论坛

 找回密码
 立即注册
查看: 2112|回复: 10

爬虫:正在打开中,请稍后...

[复制链接]
发表于 2020-2-21 22:33:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
请问这种情况咋办啊?
  1. from bs4 import BeautifulSoup
  2. import requests
  3. import io
  4. import sys
  5. import re

  6. #url
  7. #sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')


  8. #headers={User-Agent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',}
  9. headers = {
  10.     'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"
  11. }
  12. url='https://www.guazi.com/cs/buy/o3/#bread'
  13. #模拟浏览器发送请求或许相应
  14. resp=requests.get(url,headers=headers)
  15. #print(resp.text)#文本形式
  16. #html=resp.content.decode()#二进制形式
  17. html=resp.content.decode()
  18. print(html)
复制代码


捕获.PNG
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-2-21 23:04:08 | 显示全部楼层
headers 里面还要加上 Cookie 参数
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-2-21 23:05:36 | 显示全部楼层
°蓝鲤歌蓝 发表于 2020-2-21 23:04
headers 里面还要加上 Cookie 参数

其实这个我也加了,发现没啥用就给删了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-2-21 23:16:56 | 显示全部楼层
苏绛雪 发表于 2020-2-21 23:05
其实这个我也加了,发现没啥用就给删了

我的是可以的,只加了 User-Agent 和cookie
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-2-22 00:02:05 | 显示全部楼层
°蓝鲤歌蓝 发表于 2020-2-21 23:16
我的是可以的,只加了 User-Agent 和cookie

把你的Headers和Cookies复制给我用一下可好
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-2-22 00:04:17 | 显示全部楼层
苏绛雪 发表于 2020-2-22 00:02
把你的Headers和Cookies复制给我用一下可好
  1. import requests

  2. headers = {
  3.     'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36",
  4.     'Cookie': 'antipas=04408186y9630m4800m; uuid=6325ceae-74e6-4263-da25-0ee65e8c7e08; cityDomain=cs; clueSourceCode=%2A%2300; user_city_id=204; ganji_uuid=1648696376621876843367; sessionid=18e6ce90-3127-4d8e-ed61-28f7863e1b95; lg=1; cainfo=%7B%22ca_a%22%3A%22-%22%2C%22ca_b%22%3A%22-%22%2C%22ca_s%22%3A%22self%22%2C%22ca_n%22%3A%22self%22%2C%22ca_medium%22%3A%22-%22%2C%22ca_term%22%3A%22-%22%2C%22ca_content%22%3A%22-%22%2C%22ca_campaign%22%3A%22-%22%2C%22ca_kw%22%3A%22-%22%2C%22ca_i%22%3A%22-%22%2C%22scode%22%3A%22-%22%2C%22keyword%22%3A%22-%22%2C%22ca_keywordid%22%3A%22-%22%2C%22display_finance_flag%22%3A%22-%22%2C%22platform%22%3A%221%22%2C%22version%22%3A1%2C%22client_ab%22%3A%22-%22%2C%22guid%22%3A%226325ceae-74e6-4263-da25-0ee65e8c7e08%22%2C%22ca_city%22%3A%22gz%22%2C%22sessionid%22%3A%2218e6ce90-3127-4d8e-ed61-28f7863e1b95%22%7D; preTime=%7B%22last%22%3A1582296921%2C%22this%22%3A1582296885%2C%22pre%22%3A1582296885%7D'
  5. }
  6. url='https://www.guazi.com/cs/buy/o3/#bread'
  7. #模拟浏览器发送请求或许相应
  8. resp=requests.get(url,headers=headers)
  9. resp.encoding = "utf-8"
  10. html=resp.text
  11. print(html)
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-2-22 04:14:35 | 显示全部楼层
本帖最后由 yjsx86 于 2020-2-22 04:29 编辑

楼上说的是正确的, 需要加cookies, 而且只要加 antipas 字段就可以
下面是js代码混淆解出来的数据
  1. function safeAdd(x, y) {
  2.         var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  3.         var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  4.         return (msw << 16) | (lsw & 0xFFFF)
  5. }

  6. function bitRotateLeft(num, cnt) {
  7.         return (num << cnt) | (num >>> (32 - cnt))
  8. }

  9. function cmn(q, a, b, x, s, t) {
  10.         return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
  11. }

  12. function ff(a, b, c, d, x, s, t) {
  13.         return cmn((b & c) | ((~b) & d), a, b, x, s, t)
  14. }

  15. function gg(a, b, c, d, x, s, t) {
  16.         return cmn((b & d) | (c & (~d)), a, b, x, s, t)
  17. }

  18. function hh(a, b, c, d, x, s, t) {
  19.         return cmn(b ^ c ^ d, a, b, x, s, t)
  20. }

  21. function ii(a, b, c, d, x, s, t) {
  22.         return cmn(c ^ (b | (~d)), a, b, x, s, t)
  23. }

  24. function binl(x, len) {
  25.         x[len >> 5] |= 0x80 << (len % 32);
  26.         x[(((len + 64) >>> 9) << 4) + 14] = len;
  27.         var i;
  28.         var olda;
  29.         var oldb;
  30.         var oldc;
  31.         var oldd;
  32.         var a = 1732584193;
  33.         var b = -271733879;
  34.         var c = -1732584194;
  35.         var d = 271733878;
  36.         for (i = 0; i < x.length; i += 16) {
  37.                 olda = a;
  38.                 oldb = b;
  39.                 oldc = c;
  40.                 oldd = d;
  41.                 a = ff(a, b, c, d, x[i], 7, -680876936);
  42.                 d = ff(d, a, b, c, x[i + 1], 12, -389564586);
  43.                 c = ff(c, d, a, b, x[i + 2], 17, 606105819);
  44.                 b = ff(b, c, d, a, x[i + 3], 22, -1044525330);
  45.                 a = ff(a, b, c, d, x[i + 4], 7, -176418897);
  46.                 d = ff(d, a, b, c, x[i + 5], 12, 1200080426);
  47.                 c = ff(c, d, a, b, x[i + 6], 17, -1473231341);
  48.                 b = ff(b, c, d, a, x[i + 7], 22, -45705983);
  49.                 a = ff(a, b, c, d, x[i + 8], 7, 1770035416);
  50.                 d = ff(d, a, b, c, x[i + 9], 12, -1958414417);
  51.                 c = ff(c, d, a, b, x[i + 10], 17, -42063);
  52.                 b = ff(b, c, d, a, x[i + 11], 22, -1990404162);
  53.                 a = ff(a, b, c, d, x[i + 12], 7, 1804603682);
  54.                 d = ff(d, a, b, c, x[i + 13], 12, -40341101);
  55.                 c = ff(c, d, a, b, x[i + 14], 17, -1502002290);
  56.                 b = ff(b, c, d, a, x[i + 15], 22, 1236535329);
  57.                 a = gg(a, b, c, d, x[i + 1], 5, -165796510);
  58.                 d = gg(d, a, b, c, x[i + 6], 9, -1069501632);
  59.                 c = gg(c, d, a, b, x[i + 11], 14, 643717713);
  60.                 b = gg(b, c, d, a, x[i], 20, -373897302);
  61.                 a = gg(a, b, c, d, x[i + 5], 5, -701558691);
  62.                 d = gg(d, a, b, c, x[i + 10], 9, 38016083);
  63.                 c = gg(c, d, a, b, x[i + 15], 14, -660478335);
  64.                 b = gg(b, c, d, a, x[i + 4], 20, -405537848);
  65.                 a = gg(a, b, c, d, x[i + 9], 5, 568446438);
  66.                 d = gg(d, a, b, c, x[i + 14], 9, -1019803690);
  67.                 c = gg(c, d, a, b, x[i + 3], 14, -187363961);
  68.                 b = gg(b, c, d, a, x[i + 8], 20, 1163531501);
  69.                 a = gg(a, b, c, d, x[i + 13], 5, -1444681467);
  70.                 d = gg(d, a, b, c, x[i + 2], 9, -51403784);
  71.                 c = gg(c, d, a, b, x[i + 7], 14, 1735328473);
  72.                 b = gg(b, c, d, a, x[i + 12], 20, -1926607734);
  73.                 a = hh(a, b, c, d, x[i + 5], 4, -378558);
  74.                 d = hh(d, a, b, c, x[i + 8], 11, -2022574463);
  75.                 c = hh(c, d, a, b, x[i + 11], 16, 1839030562);
  76.                 b = hh(b, c, d, a, x[i + 14], 23, -35309556);
  77.                 a = hh(a, b, c, d, x[i + 1], 4, -1530992060);
  78.                 d = hh(d, a, b, c, x[i + 4], 11, 1272893353);
  79.                 c = hh(c, d, a, b, x[i + 7], 16, -155497632);
  80.                 b = hh(b, c, d, a, x[i + 10], 23, -1094730640);
  81.                 a = hh(a, b, c, d, x[i + 13], 4, 681279174);
  82.                 d = hh(d, a, b, c, x[i], 11, -358537222);
  83.                 c = hh(c, d, a, b, x[i + 3], 16, -722521979);
  84.                 b = hh(b, c, d, a, x[i + 6], 23, 76029189);
  85.                 a = hh(a, b, c, d, x[i + 9], 4, -640364487);
  86.                 d = hh(d, a, b, c, x[i + 12], 11, -421815835);
  87.                 c = hh(c, d, a, b, x[i + 15], 16, 530742520);
  88.                 b = hh(b, c, d, a, x[i + 2], 23, -995338651);
  89.                 a = ii(a, b, c, d, x[i], 6, -198630844);
  90.                 d = ii(d, a, b, c, x[i + 7], 10, 1126891415);
  91.                 c = ii(c, d, a, b, x[i + 14], 15, -1416354905);
  92.                 b = ii(b, c, d, a, x[i + 5], 21, -57434055);
  93.                 a = ii(a, b, c, d, x[i + 12], 6, 1700485571);
  94.                 d = ii(d, a, b, c, x[i + 3], 10, -1894986606);
  95.                 c = ii(c, d, a, b, x[i + 10], 15, -1051523);
  96.                 b = ii(b, c, d, a, x[i + 1], 21, -2054922799);
  97.                 a = ii(a, b, c, d, x[i + 8], 6, 1873313359);
  98.                 d = ii(d, a, b, c, x[i + 15], 10, -30611744);
  99.                 c = ii(c, d, a, b, x[i + 6], 15, -1560198380);
  100.                 b = ii(b, c, d, a, x[i + 13], 21, 1309151649);
  101.                 a = ii(a, b, c, d, x[i + 4], 6, -145523070);
  102.                 d = ii(d, a, b, c, x[i + 11], 10, -1120210379);
  103.                 c = ii(c, d, a, b, x[i + 2], 15, 718787259);
  104.                 b = ii(b, c, d, a, x[i + 9], 21, -343485551);
  105.                 a = safeAdd(a, olda);
  106.                 b = safeAdd(b, oldb);
  107.                 c = safeAdd(c, oldc);
  108.                 d = safeAdd(d, oldd)
  109.         }
  110.         return [a, b, c, d]
  111. }

  112. function binl2rstr(input) {
  113.         var i;
  114.         var output = '';
  115.         var length32 = input.length * 32;
  116.         for (i = 0; i < length32; i += 8) {
  117.                 output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF)
  118.         }
  119.         return output
  120. }

  121. function rstr2binl(input) {
  122.         var i;
  123.         var output = [];
  124.         output[(input.length >> 2) - 1] = undefined;
  125.         for (i = 0; i < output.length; i += 1) {
  126.                 output[i] = 0
  127.         }
  128.         var length8 = input.length * 8;
  129.         for (i = 0; i < length8; i += 8) {
  130.                 output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32)
  131.         }
  132.         return output
  133. }

  134. function rstr(s) {
  135.         return binl2rstr(binl(rstr2binl(s), s.length * 8))
  136. }

  137. function rstrHMAC(key, data) {
  138.         var i;
  139.         var bkey = rstr2binl(key);
  140.         var ipad = [];
  141.         var opad = [];
  142.         var hash;
  143.         ipad[15] = opad[15] = undefined;
  144.         if (bkey.length > 16) {
  145.                 bkey = binl(bkey, key.length * 8)
  146.         }
  147.         for (i = 0; i < 16; i += 1) {
  148.                 ipad[i] = bkey[i] ^ 0x36363636;
  149.                 opad[i] = bkey[i] ^ 0x5C5C5C5C
  150.         }
  151.         hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
  152.         return binl2rstr(binl(opad.concat(hash), 512 + 128))
  153. }

  154. function rstr2hex(input) {
  155.         var hexTab = '0123456789abcdef';
  156.         var output = '';
  157.         var x;
  158.         var i;
  159.         for (i = 0; i < input.length; i += 1) {
  160.                 x = input.charCodeAt(i);
  161.                 output += hexTab.charAt((x >>> 4) & 0x0F) + hexTab.charAt(x & 0x0F)
  162.         }
  163.         return output
  164. }

  165. function str2rstrUTF8(input) {
  166.         return unescape(encodeURIComponent(input))
  167. }

  168. function raw(s) {
  169.         return rstr(str2rstrUTF8(s))
  170. }

  171. function hex(s) {
  172.         return rstr2hex(raw(s))
  173. }

  174. function uid() {
  175.         var text = "";
  176.         var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  177.         var len = Math.floor(Math.random() * 2);
  178.         for (var i = 0; i < len; i++) {
  179.                 text += possible.charAt(Math.floor(Math.random() * possible.length))
  180.         }
  181.         return text
  182. }

  183. function charRun(s) {
  184.         s = s.replace(/[a-zA-Z]/g, '#');
  185.         var arr = s.split('');
  186.         for (var i = 0; i < arr.length; i++) {
  187.                 if (arr[i] == '#') {
  188.                         arr[i] = uid()
  189.                 }
  190.         }
  191.         return arr.join('')
  192. }

  193. function anti(string, key) {
  194.         var estring = hex(string);
  195.         return charRun(estring)
  196. }

  197. function xredirect(name, value, url) {
  198.         var date = new Date();
  199.         date.setTime(date.getTime() + 2592000000);
  200.         var expires = "; expires=" + date.toUTCString();
  201.         document.cookie = name + "=" + value + expires + "; path=/";
  202.         if (document.cookie.indexOf(name) === -1 && navigator.cookieEnabled) {
  203.                 alert('请修改浏览器设置,允许cookie缓存')
  204.         } else {
  205.                 if (url == '') {
  206.                         var url = location.href;
  207.                         if (location.protocol != 'https:') {
  208.                                 url = 'https:' + window.location.href.substring(window.location.protocol.length)
  209.                         }
  210.                 } else {
  211.                         if (location.protocol != 'https:') {
  212.                                 url = 'https:' + url
  213.                         }
  214.                 }
  215.                 var ulen = url.indexOf('#');
  216.                 if (ulen !== -1) {
  217.                         url = url.substring(0, ulen)
  218.                 }
  219.                 location.replace(url)
  220.         }
  221. }
  222. var value=anti('nEQQ8Bx8mcU3rM1nheGz1E0XBUO3Y+/oHOd8ubI+8tI=','596766188673376496');
  223. var name='antipas';
  224. var url='';
  225. xredirect(name,value,url,'https://')
复制代码

从 xredirect 方法的定义里可以看到, cookies 加了3个字段 antipas expires path, 按经验来说只有第一个起关键作用, 我试验了下确实是

给你段稍微完整点的代码, 只是个演示
  1. import execjs
  2. import requests
  3. import re


  4. jscode = '''
  5. function safeAdd(x, y) {
  6.         var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  7.         var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  8.         return (msw << 16) | (lsw & 0xFFFF)
  9. }

  10. function bitRotateLeft(num, cnt) {
  11.         return (num << cnt) | (num >>> (32 - cnt))
  12. }

  13. function cmn(q, a, b, x, s, t) {
  14.         return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
  15. }

  16. function ff(a, b, c, d, x, s, t) {
  17.         return cmn((b & c) | ((~b) & d), a, b, x, s, t)
  18. }

  19. function gg(a, b, c, d, x, s, t) {
  20.         return cmn((b & d) | (c & (~d)), a, b, x, s, t)
  21. }

  22. function hh(a, b, c, d, x, s, t) {
  23.         return cmn(b ^ c ^ d, a, b, x, s, t)
  24. }

  25. function ii(a, b, c, d, x, s, t) {
  26.         return cmn(c ^ (b | (~d)), a, b, x, s, t)
  27. }

  28. function binl(x, len) {
  29.         x[len >> 5] |= 0x80 << (len % 32);
  30.         x[(((len + 64) >>> 9) << 4) + 14] = len;
  31.         var i;
  32.         var olda;
  33.         var oldb;
  34.         var oldc;
  35.         var oldd;
  36.         var a = 1732584193;
  37.         var b = -271733879;
  38.         var c = -1732584194;
  39.         var d = 271733878;
  40.         for (i = 0; i < x.length; i += 16) {
  41.                 olda = a;
  42.                 oldb = b;
  43.                 oldc = c;
  44.                 oldd = d;
  45.                 a = ff(a, b, c, d, x[i], 7, -680876936);
  46.                 d = ff(d, a, b, c, x[i + 1], 12, -389564586);
  47.                 c = ff(c, d, a, b, x[i + 2], 17, 606105819);
  48.                 b = ff(b, c, d, a, x[i + 3], 22, -1044525330);
  49.                 a = ff(a, b, c, d, x[i + 4], 7, -176418897);
  50.                 d = ff(d, a, b, c, x[i + 5], 12, 1200080426);
  51.                 c = ff(c, d, a, b, x[i + 6], 17, -1473231341);
  52.                 b = ff(b, c, d, a, x[i + 7], 22, -45705983);
  53.                 a = ff(a, b, c, d, x[i + 8], 7, 1770035416);
  54.                 d = ff(d, a, b, c, x[i + 9], 12, -1958414417);
  55.                 c = ff(c, d, a, b, x[i + 10], 17, -42063);
  56.                 b = ff(b, c, d, a, x[i + 11], 22, -1990404162);
  57.                 a = ff(a, b, c, d, x[i + 12], 7, 1804603682);
  58.                 d = ff(d, a, b, c, x[i + 13], 12, -40341101);
  59.                 c = ff(c, d, a, b, x[i + 14], 17, -1502002290);
  60.                 b = ff(b, c, d, a, x[i + 15], 22, 1236535329);
  61.                 a = gg(a, b, c, d, x[i + 1], 5, -165796510);
  62.                 d = gg(d, a, b, c, x[i + 6], 9, -1069501632);
  63.                 c = gg(c, d, a, b, x[i + 11], 14, 643717713);
  64.                 b = gg(b, c, d, a, x[i], 20, -373897302);
  65.                 a = gg(a, b, c, d, x[i + 5], 5, -701558691);
  66.                 d = gg(d, a, b, c, x[i + 10], 9, 38016083);
  67.                 c = gg(c, d, a, b, x[i + 15], 14, -660478335);
  68.                 b = gg(b, c, d, a, x[i + 4], 20, -405537848);
  69.                 a = gg(a, b, c, d, x[i + 9], 5, 568446438);
  70.                 d = gg(d, a, b, c, x[i + 14], 9, -1019803690);
  71.                 c = gg(c, d, a, b, x[i + 3], 14, -187363961);
  72.                 b = gg(b, c, d, a, x[i + 8], 20, 1163531501);
  73.                 a = gg(a, b, c, d, x[i + 13], 5, -1444681467);
  74.                 d = gg(d, a, b, c, x[i + 2], 9, -51403784);
  75.                 c = gg(c, d, a, b, x[i + 7], 14, 1735328473);
  76.                 b = gg(b, c, d, a, x[i + 12], 20, -1926607734);
  77.                 a = hh(a, b, c, d, x[i + 5], 4, -378558);
  78.                 d = hh(d, a, b, c, x[i + 8], 11, -2022574463);
  79.                 c = hh(c, d, a, b, x[i + 11], 16, 1839030562);
  80.                 b = hh(b, c, d, a, x[i + 14], 23, -35309556);
  81.                 a = hh(a, b, c, d, x[i + 1], 4, -1530992060);
  82.                 d = hh(d, a, b, c, x[i + 4], 11, 1272893353);
  83.                 c = hh(c, d, a, b, x[i + 7], 16, -155497632);
  84.                 b = hh(b, c, d, a, x[i + 10], 23, -1094730640);
  85.                 a = hh(a, b, c, d, x[i + 13], 4, 681279174);
  86.                 d = hh(d, a, b, c, x[i], 11, -358537222);
  87.                 c = hh(c, d, a, b, x[i + 3], 16, -722521979);
  88.                 b = hh(b, c, d, a, x[i + 6], 23, 76029189);
  89.                 a = hh(a, b, c, d, x[i + 9], 4, -640364487);
  90.                 d = hh(d, a, b, c, x[i + 12], 11, -421815835);
  91.                 c = hh(c, d, a, b, x[i + 15], 16, 530742520);
  92.                 b = hh(b, c, d, a, x[i + 2], 23, -995338651);
  93.                 a = ii(a, b, c, d, x[i], 6, -198630844);
  94.                 d = ii(d, a, b, c, x[i + 7], 10, 1126891415);
  95.                 c = ii(c, d, a, b, x[i + 14], 15, -1416354905);
  96.                 b = ii(b, c, d, a, x[i + 5], 21, -57434055);
  97.                 a = ii(a, b, c, d, x[i + 12], 6, 1700485571);
  98.                 d = ii(d, a, b, c, x[i + 3], 10, -1894986606);
  99.                 c = ii(c, d, a, b, x[i + 10], 15, -1051523);
  100.                 b = ii(b, c, d, a, x[i + 1], 21, -2054922799);
  101.                 a = ii(a, b, c, d, x[i + 8], 6, 1873313359);
  102.                 d = ii(d, a, b, c, x[i + 15], 10, -30611744);
  103.                 c = ii(c, d, a, b, x[i + 6], 15, -1560198380);
  104.                 b = ii(b, c, d, a, x[i + 13], 21, 1309151649);
  105.                 a = ii(a, b, c, d, x[i + 4], 6, -145523070);
  106.                 d = ii(d, a, b, c, x[i + 11], 10, -1120210379);
  107.                 c = ii(c, d, a, b, x[i + 2], 15, 718787259);
  108.                 b = ii(b, c, d, a, x[i + 9], 21, -343485551);
  109.                 a = safeAdd(a, olda);
  110.                 b = safeAdd(b, oldb);
  111.                 c = safeAdd(c, oldc);
  112.                 d = safeAdd(d, oldd)
  113.         }
  114.         return [a, b, c, d]
  115. }

  116. function binl2rstr(input) {
  117.         var i;
  118.         var output = '';
  119.         var length32 = input.length * 32;
  120.         for (i = 0; i < length32; i += 8) {
  121.                 output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF)
  122.         }
  123.         return output
  124. }

  125. function rstr2binl(input) {
  126.         var i;
  127.         var output = [];
  128.         output[(input.length >> 2) - 1] = undefined;
  129.         for (i = 0; i < output.length; i += 1) {
  130.                 output[i] = 0
  131.         }
  132.         var length8 = input.length * 8;
  133.         for (i = 0; i < length8; i += 8) {
  134.                 output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32)
  135.         }
  136.         return output
  137. }

  138. function rstr(s) {
  139.         return binl2rstr(binl(rstr2binl(s), s.length * 8))
  140. }

  141. function rstrHMAC(key, data) {
  142.         var i;
  143.         var bkey = rstr2binl(key);
  144.         var ipad = [];
  145.         var opad = [];
  146.         var hash;
  147.         ipad[15] = opad[15] = undefined;
  148.         if (bkey.length > 16) {
  149.                 bkey = binl(bkey, key.length * 8)
  150.         }
  151.         for (i = 0; i < 16; i += 1) {
  152.                 ipad[i] = bkey[i] ^ 0x36363636;
  153.                 opad[i] = bkey[i] ^ 0x5C5C5C5C
  154.         }
  155.         hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
  156.         return binl2rstr(binl(opad.concat(hash), 512 + 128))
  157. }

  158. function rstr2hex(input) {
  159.         var hexTab = '0123456789abcdef';
  160.         var output = '';
  161.         var x;
  162.         var i;
  163.         for (i = 0; i < input.length; i += 1) {
  164.                 x = input.charCodeAt(i);
  165.                 output += hexTab.charAt((x >>> 4) & 0x0F) + hexTab.charAt(x & 0x0F)
  166.         }
  167.         return output
  168. }

  169. function str2rstrUTF8(input) {
  170.         return unescape(encodeURIComponent(input))
  171. }

  172. function raw(s) {
  173.         return rstr(str2rstrUTF8(s))
  174. }

  175. function hex(s) {
  176.         return rstr2hex(raw(s))
  177. }

  178. function uid() {
  179.         var text = "";
  180.         var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  181.         var len = Math.floor(Math.random() * 2);
  182.         for (var i = 0; i < len; i++) {
  183.                 text += possible.charAt(Math.floor(Math.random() * possible.length))
  184.         }
  185.         return text
  186. }

  187. function charRun(s) {
  188.         s = s.replace(/[a-zA-Z]/g, '#');
  189.         var arr = s.split('');
  190.         for (var i = 0; i < arr.length; i++) {
  191.                 if (arr[i] == '#') {
  192.                         arr[i] = uid()
  193.                 }
  194.         }
  195.         return arr.join('')
  196. }

  197. function anti(string, key) {
  198.         var estring = hex(string);
  199.         return charRun(estring)
  200. }

  201. function xredirect(name, value, url) {
  202.         var date = new Date();
  203.         date.setTime(date.getTime() + 2592000000);
  204.         var expires = "; expires=" + date.toUTCString();
  205.         document.cookie = name + "=" + value + expires + "; path=/";
  206.         if (document.cookie.indexOf(name) === -1 && navigator.cookieEnabled) {
  207.                 alert('请修改浏览器设置,允许cookie缓存')
  208.         } else {
  209.                 if (url == '') {
  210.                         var url = location.href;
  211.                         if (location.protocol != 'https:') {
  212.                                 url = 'https:' + window.location.href.substring(window.location.protocol.length)
  213.                         }
  214.                 } else {
  215.                         if (location.protocol != 'https:') {
  216.                                 url = 'https:' + url
  217.                         }
  218.                 }
  219.                 var ulen = url.indexOf('#');
  220.                 if (ulen !== -1) {
  221.                         url = url.substring(0, ulen)
  222.                 }
  223.                 location.replace(url)
  224.         }
  225. }
  226. var name='antipas';

  227. '''
  228. headers = {
  229.     'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36"
  230. }

  231. url = 'https://www.guazi.com/cs/buy/o3/#bread'
  232. session = requests.Session()

  233. resp = session.get(url, headers=headers)
  234. resp.encoding = "utf-8"
  235. rs = re.findall(r"var value=(anti\(.*?\));", resp.text)
  236. ctx = execjs.compile(jscode)
  237. v = ctx.eval(rs[0])
  238. cookies = {
  239.     "antipas": v
  240. }
  241. resp = session.get(url, headers=headers, cookies=cookies)
  242. print(resp.text)
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-2-22 10:11:38 | 显示全部楼层

我很感谢你回答,但是 不得不说,这样还是不行。我重新发一个帖子,把错误的图片附上去
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-2-22 10:15:15 | 显示全部楼层
yjsx86 发表于 2020-2-22 04:14
楼上说的是正确的, 需要加cookies, 而且只要加 antipas 字段就可以
下面是js代码混淆解出来的数据

楼上的代码是错的,我重新发了个帖子。报错原因也在帖子上
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-2-22 13:26:02 | 显示全部楼层
苏绛雪 发表于 2020-2-22 10:15
楼上的代码是错的,我重新发了个帖子。报错原因也在帖子上

你用我提供的代码 也还是不行么?
你运行 我的代码 错误是什么?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-2-22 15:03:04 | 显示全部楼层
yjsx86 发表于 2020-2-22 13:26
你用我提供的代码 也还是不行么?
你运行 我的代码 错误是什么?

感觉你的代码太复杂了,根本看不懂
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-22 16:50

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表