本文整理汇总了Python中js2py.EvalJs方法的典型用法代码示例。如果您正苦于以下问题:Python js2py.EvalJs方法的具体用法?Python js2py.EvalJs怎么用?Python js2py.EvalJs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js2py
的用法示例。
在下文中一共展示了js2py.EvalJs方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def eval(self, body, domain):
jsPayload = template(body, domain)
if js2py.eval_js('(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]') == '1':
logging.warning('WARNING - Please upgrade your js2py https://github.com/PiotrDabkowski/Js2Py, applying work around for the meantime.')
jsPayload = jsunfuck(jsPayload)
def atob(s):
return base64.b64decode('{}'.format(s)).decode('utf-8')
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
result = context.eval(jsPayload)
return result
# ------------------------------------------------------------------------------- #
示例2: getSign
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def getSign(self, gtk, word):
evaljs = js2py.EvalJs()
js_code = js.bd_js_code
js_code = js_code.replace('null !== i ? i : (i = window[l] || "") || ""', gtk)
evaljs.execute(js_code)
sign = evaljs.e(word)
return sign
示例3: getTk
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def getTk(self, word):
evaljs = js2py.EvalJs()
js_code = js.gg_js_code
evaljs.execute(js_code)
tk = evaljs.TL(word)
return tk
示例4: decode_url
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def decode_url(data):
import js2py
import re
data = re.sub(r'\n|\r|\t| |<br>|\s{2,}', "", data)
js = scrapertools.find_single_match(data, '<script>(l.*?)</script>')
part = js.split("+ll")
part0 = part[1].split("String['fromCharCode'")[0]
part1 = part[1].replace(part0, "")
part1 = re.sub(r'(l.*?)\(\(\[', 'window.btoa(([', part1)
logger.info("zebiiiii-%s" % part1)
context = js2py.EvalJs({ "btoa": btoa });
url = "htt%s" % context.eval(part1)
logger.info(url)
return url
示例5: eval
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def eval(self, jsEnv, js):
if js2py.eval_js('(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]') == '1':
logging.warning('WARNING - Please upgrade your js2py https://github.com/PiotrDabkowski/Js2Py, applying work around for the meantime.')
js = jsunfuck(js)
def atob(s):
return base64.b64decode('{}'.format(s)).decode('utf-8')
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
result = context.eval('{}{}'.format(jsEnv, js))
return result
示例6: solve_66ip
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def solve_66ip(self, response):
"""
处理66ip的js加密
:param response: 第一次请求返回的js数据
:return: 返回解密好的网页数据
"""
cookie = response.headers["Set-Cookie"]
js = response.text.encode("utf8").decode("utf8")
js = js.replace("<script>", "").replace("</script>", "").replace("{eval(", "{var data1 = (").replace(chr(0),
chr(32))
# 使用js2py处理js
context = js2py.EvalJs()
context.execute(js)
js_temp = context.data1
index1 = js_temp.find("document.")
index2 = js_temp.find("};if((")
print('11', js_temp[index1:index2])
js_temp = js_temp[index1:index2].replace("document.cookie", "data2")
print('22', js_temp)
try:
context.execute(js_temp)
except Exception as e:
# time.sleep(2)
# context.execute(js_temp)
pass
data = context.data2
# 合并cookie,重新请求网站。
cookie += ";" + data
response = requests.get("http://www.66ip.cn/mo.php?tqsl=1024", headers={
"User-Agent": self.user_agent_66ip,
"cookie": cookie
}, timeout=(3, 7))
return response
示例7: js2py_conversion
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def js2py_conversion(data, url, post=None, follow_redirects=True, headers={}):
logger.info()
import js2py
import base64
if not 'Javascript is required' in data:
return data
patron = ',\s*S="([^"]+)"'
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
patron = ",\s*S='([^']+)'"
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
logger.error('js2py_conversion: NO data_new')
return data
try:
for x in range(10): # Da hasta 10 pasadas o hasta que de error
data_end = base64.b64decode(data_new).decode('utf-8')
data_new = data_end
except:
js2py_code = data_new
else:
logger.error('js2py_conversion: base64 data_new NO Funciona: ' + str(data_new))
return data
if not js2py_code:
logger.error('js2py_conversion: NO js2py_code BASE64')
return data
js2py_code = js2py_code.replace('document', 'window').replace(" location.reload();", "")
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
new_cookie = context.eval(js2py_code)
logger.info('new_cookie: ' + new_cookie)
dict_cookie = {'domain': domain,
}
if ';' in new_cookie:
new_cookie = new_cookie.split(';')[0].strip()
namec, valuec = new_cookie.split('=')
dict_cookie['name'] = namec.strip()
dict_cookie['value'] = valuec.strip()
zanga = httptools.set_cookies(dict_cookie)
data_new = ''
data_new = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(url, \
timeout=timeout, headers=headers, post=post, follow_redirects=follow_redirects).data)
data_new = re.sub('\r\n', '', data_new).decode('utf8').encode('utf8')
if data_new:
data = data_new
return data
示例8: js2py_conversion
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def js2py_conversion(data, url, post=None, follow_redirects=True):
logger.info()
import js2py
import base64
if not 'Javascript is required' in data:
return data
patron = ',\s*S="([^"]+)"'
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
patron = ",\s*S='([^']+)'"
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
logger.error('js2py_conversion: NO data_new')
return data
try:
for x in range(10): # Da hasta 10 pasadas o hasta que de error
data_end = base64.b64decode(data_new).decode('utf-8')
data_new = data_end
except:
js2py_code = data_new
else:
logger.error('js2py_conversion: base64 data_new NO Funciona: ' + str(data_new))
return data
if not js2py_code:
logger.error('js2py_conversion: NO js2py_code BASE64')
return data
js2py_code = js2py_code.replace('document', 'window').replace(" location.reload();", "")
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
new_cookie = context.eval(js2py_code)
logger.info('new_cookie: ' + new_cookie)
dict_cookie = {'domain': domain,
}
if ';' in new_cookie:
new_cookie = new_cookie.split(';')[0].strip()
namec, valuec = new_cookie.split('=')
dict_cookie['name'] = namec.strip()
dict_cookie['value'] = valuec.strip()
zanga = httptools.set_cookies(dict_cookie)
data_new = ''
data_new = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(url, \
timeout=timeout, headers=headers, post=post, follow_redirects=follow_redirects).data)
data_new = re.sub('\r\n', '', data_new).decode('utf8').encode('utf8')
if data_new:
data = data_new
return data
示例9: js2py_conversion
# 需要导入模块: import js2py [as 别名]
# 或者: from js2py import EvalJs [as 别名]
def js2py_conversion(data, url, post=None, domain_name=domain, headers={}, timeout=timeout, follow_redirects=True):
logger.info()
if not 'Javascript is required' in data:
return data
patron = ',\s*S="([^"]+)"'
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
patron = ",\s*S='([^']+)'"
data_new = scrapertools.find_single_match(data, patron)
if not data_new:
logger.error('js2py_conversion: NO data_new')
return data
try:
for x in range(10): # Da hasta 10 pasadas o hasta que de error
data_end = base64.b64decode(data_new).decode('utf-8')
data_new = data_end
except:
js2py_code = data_new
else:
logger.error('js2py_conversion: base64 data_new NO Funciona: ' + str(data_new))
return data
if not js2py_code:
logger.error('js2py_conversion: NO js2py_code BASE64')
return data
js2py_code = js2py_code.replace('document', 'window').replace(" location.reload();", "")
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
new_cookie = context.eval(js2py_code)
new_cookie = context.eval(js2py_code)
logger.info('new_cookie: ' + new_cookie)
dict_cookie = {'domain': domain_name,
}
if ';' in new_cookie:
new_cookie = new_cookie.split(';')[0].strip()
namec, valuec = new_cookie.split('=')
dict_cookie['name'] = namec.strip()
dict_cookie['value'] = valuec.strip()
zanga = httptools.set_cookies(dict_cookie)
config.set_setting("cookie_ren", True, channel=channel)
data_new = ''
data_new = re.sub(r"\n|\r|\t|(<!--.*?-->)", "", httptools.downloadpage(url, \
timeout=timeout, headers=headers, post=post, follow_redirects=follow_redirects).data)
#data_new = re.sub('\r\n', '', data_new).decode('utf8').encode('utf8')
if data_new:
data = data_new
return data