鱼C论坛

 找回密码
 立即注册
查看: 2412|回复: 1

execjs报错

[复制链接]
发表于 2020-10-16 17:47:23 | 显示全部楼层 |阅读模式

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

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

x
爬虫,遇到几个元素是js生成的,就复制过来然后execjs执行,结果报了错:
  1. Traceback (most recent call last):
  2.   File "C:/MyPythonProjects/WebSpideFile/EnglishPlayer.py", line 22, in <module>
  3.     test = js.call('empty')
  4.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_abstract_runtime_context.py", line 37, in call
  5.     return self._call(name, *args)
  6.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_external_runtime.py", line 92, in _call
  7.     return self._eval("{identifier}.apply(this, {args})".format(identifier=identifier, args=args))
  8.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_external_runtime.py", line 78, in _eval
  9.     return self.exec_(code)
  10.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_abstract_runtime_context.py", line 18, in exec_
  11.     return self._exec_(source)
  12.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_external_runtime.py", line 88, in _exec_
  13.     return self._extract_result(output)
  14.   File "C:\Users\fengu\AppData\Local\Programs\Python\Python38\lib\site-packages\execjs\_external_runtime.py", line 167, in _extract_result
  15.     raise ProgramError(value)
  16. execjs._exceptions.ProgramError: None
复制代码

这不是重点,重点是错误内容是None,None,None......
那我上哪里改正去?
这是js代码:
  1. var ma = /<(?:script|style|link)/i,

  2.     type = function(a) {
  3.             return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h[i.call(a)] || "object" : typeof a
  4.             },
  5.     empty = function() {
  6.             for (var a, b = 0; null != (a = this[b]); b++) {
  7.                 1 === a.nodeType && m.cleanData(ua(a, !1));
  8.                 while (a.firstChild)
  9.                     a.removeChild(a.firstChild);
  10.                 a.options && m.nodeName(a, "select") && (a.options.length = 0)
  11.             }
  12.             a = this
  13.             return a
  14.         },

  15.     m = function(a, b) {
  16.         return new m.fn.init(a,b)
  17.     },
  18.     isFunction = function(a) {
  19.             return "function" === type(a)
  20.         },
  21.     v = access = function(a, b, c, d, e, f, g) {
  22.         var h = 0
  23.           , i = a.length
  24.           , j = null == c;
  25.         if ("object" === type(c)) {
  26.             e = !0;
  27.             for (h in c)
  28.                 access(a, b, h, c[h], !0, f, g)
  29.         } else if (void 0 !== d && (e = !0,
  30.         isFunction(d) || (g = !0),
  31.         j && (g ? (b.call(a, d),
  32.         b = null) : (j = b,
  33.         b = function(a, b, c) {
  34.             return j.call(m(a), c)
  35.         }
  36.         )),
  37.         b))
  38.             for (; i > h; h++)
  39.                 b(a[h], c, g ? d : d.call(a[h], h, b(a[h], c)));
  40.         return e ? a : j ? b.call(a) : i ? b(a[0], c) : f
  41.     }
  42. console.log(empty())
  43. function n(a) {
  44.         console.log(this)
  45.         return v(this, function(a) {
  46.             var b = this[0] || {}
  47.               , c = 0
  48.               , d = this.length;
  49.             if (void 0 === a)
  50.                 return 1 === b.nodeType ? b.innerHTML.replace(fa, "") : void 0;
  51.             if (!("string" != typeof a || ma.test(a) || !true && ga.test(a) || !true && ha.test(a) || ra[(ja.exec(a) || ["", ""])[1].toLowerCase()])) {
  52.                 a = a.replace(ia, "<$1></$2>");
  53.                 try {
  54.                     for (; d > c; c++)
  55.                         b = this[c] || {},
  56.                         1 === b.nodeType && (m.cleanData(ua(b, !1)),
  57.                         b.innerHTML = a);
  58.                     b = 0
  59.                 } catch (e) {}
  60.             }
  61.             b && this.empty().append(a)
  62.         }, null, a, arguments.length)
  63. }
复制代码

哪一个会js的大佬来帮我看看哪里错了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-10-16 18:24:06 | 显示全部楼层
原来还可以这样来获取js生成的元素

你要么把全部代码放上来,看看
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-28 10:54

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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