Ejemplo n.º 1
0
def getimgurls(html, url):
	sFiles = re.search('sFiles="([^"]+)"', html).group(1)
	sPath = re.search('sPath="([^"]+)"', html).group(1)
	
	viewhtm = grabhtml("http://www.iibq.com/script/viewhtm.js")
	
	env = """
	window = {
		"eval": eval,
		"parseInt": parseInt,
		"String": String,
		"RegExp": RegExp
	};
	location = {
		"hostname": "www.iibq.com"
	};
	"""
	
	unsuan = partial(
		execjs.compile(
			env + re.search(r'(.+?)var cuImg', viewhtm, re.DOTALL).group(1)
		).call,
		"unsuan"
	)
	
	arrFiles = unsuan(sFiles).split("|")
	
	ds = grabhtml("http://www.iibq.com/script/ds.js")
	
	SLUrl = re.search('sDS = "([^"]+)"', ds).group(1).split("^")[0].split("|")[1]
	
	return [SLUrl + sPath + f for f in arrFiles]
Ejemplo n.º 2
0
Archivo: baidu.py Proyecto: sclbeta/bdy
 def create_gid(self):
     temp = execjs.compile('''function create_gid() {
         return "xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
             function(c) {var r = Math.random() * 16 | 0,v = c == "x" ? r : (r & 3 | 8);
                 return v.toString(16);})}''')
     self.gid = temp.call('create_gid')
     return self.gid
    def __setup(self):
        global src

        if not src:
            for js in ['compiler', 'handlebars', 'ember-template-compiler']:
                src += resource_string(__name__, 'js/{0}.js'.format(js))
        self.ctx = execjs.compile(src)
Ejemplo n.º 4
0
def std_encode(s):
    import base64
    import execjs

    ctx = execjs.compile("""
    btoa = function (input) {
      var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
      var str = String(input);
      for (
        // initialize result and counter
        var block, charCode, idx = 0, map = chars, output = '';
        // if the next str index does not exist:
        //   change the mapping table to "="
        //   check if d has no fractional digits
        str.charAt(idx | 0) || (map = '=', idx % 1);
        // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
        output += map.charAt(63 & block >> 8 - idx % 1 * 8)
      ) {
        charCode = str.charCodeAt(idx += 3/4);
        if (charCode > 0xFF) {
          throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
        }
        block = block << 8 | charCode;
      }
      return output;
    }
    """)
    temp = ctx.call("encodeURIComponent", s)
    return ctx.call("btoa", temp)
Ejemplo n.º 5
0
 def buildBundle(self, rebuild=None):
     """ Builds CommonJS bundle """
     rebuild =  self._rebuild_bundle if rebuild is None else rebuild
     if not os.path.exists(os.path.dirname(self._js_bundle)):
         os.makedirs(os.path.dirname(self._js_bundle))
     js_bundle_ts = os.path.getmtime(self._js_bundle) if os.path.exists(self._js_bundle) else 0
     css_bundle_ts = os.path.getmtime(self._css_bundle) if os.path.exists(self._css_bundle) else 0
     js_files_max_ts = max([os.path.getmtime(filename) for filename in self._scripts.values()]) if self._scripts else 0
     css_files_max_ts = max([os.path.getmtime(filename) for filename in self._styles.values()]) if self._styles else 0
     with open(os.path.join(os.path.dirname(__file__), 'CommonMixin.js')) as file:
         ctx = execjs.compile(file.read())
         if self._scripts and (js_files_max_ts>js_bundle_ts or rebuild):
             files = list(self._scripts.items())
             try:
                 ctx.call('bundle_scripts', self._js_bundle, self._requires, files, self._debug)
             except execjs.RuntimeError as exc:
                 raise RuntimeError('execjs.RuntimeError: {0}'.format(exc.args[0].decode('utf8')))
             logging.warning("Rebuilded: '{0}'.".format(self._js_bundle))
         if self._styles and (css_files_max_ts>css_bundle_ts or rebuild):
             files = list(self._styles.values())
             try:
                 ctx.call('bundle_styles', self._css_bundle, files, self._debug)
             except execjs.RuntimeError as exc:
                 raise RuntimeError('execjs.RuntimeError: {0}'.format(exc.args[0].decode('utf8')))
             logging.warning("Rebuilded: '{0}'.".format(self._css_bundle)) 
Ejemplo n.º 6
0
def _rsa_encrypt(session: requests.Session, url: str, modulus: str, public_exp: str, rsaiv: str, pw: str):
    """ Hilariously runs the RSA javascript with some of our own javascript injected so that we can
    get the correct ciphertext for our password.

     Eventually need to switch to using a Python library once we figure out how to do that.
    """
    rsaencrypt_response = session.get(url)
    assert rsaencrypt_response.status_code == requests.codes.ok, \
        "Unable to get RSAEncrypt.js.  Status: {}\nBody:\n{}".format(rsaencrypt_response.status_code,
                                                                     rsaencrypt_response.text)

    assert "RSAKey" in rsaencrypt_response.text, "Got unexpected content for RSA encryption."

    script_additions = """
    var navigator = {};
    var window = {};
    window.crypto = null;

    function my_encrypt(modulus, publicExponent, rsaiv, password) {
        var rsa = new RSAKey();

        rsa.setPublic(modulus, publicExponent);

        return rsa.encrypt(rsaiv + password);
    }

    function MaskElement(elem) {}
    """

    new_script = script_additions + rsaencrypt_response.text

    ctx = execjs.compile(new_script)
    return ctx.call("my_encrypt", modulus, public_exp, rsaiv, pw)
Ejemplo n.º 7
0
    def __parse_token(self, html_str):
        pattern = re.compile('\\$\\$_=.*~\\[\\];.*\"\"\\)\\(\\)\\)\\(\\);')
        match = pattern.search(html_str)
        
        if not match:
            raise "Can't find obfuscated token data."
        
        obfuscated = match.group()

        ctx = execjs.compile("""
            function getToken() {
                var token = null;
                localStorage = {
                    setItem:    function(key, value) {
                                    if (key === 'gv-token')
                                        token=value
                             }
                };
            """ +
            obfuscated +
            """
                return token;
            }"""
        )
        self.__token_value = ctx.call('getToken')
Ejemplo n.º 8
0
def init(session):
    session.head(BUS_URL)
    script_content = session.get(BUS_SCRIPT_URL, headers=headers).text

    js = execjs.compile(js_function + script_content)

    return js
Ejemplo n.º 9
0
def getimgurl(html, url, page):

	if url not in cache:
		key = search(r'id="dm5_key".+?<script[^>]+?>\s*eval(.+?)</script>', html, DOTALL)
		if key:
			key = eval(key.group(1)).split(";")[1]
			key = search(r"=(.+)$", key).group(1)
			key = eval(key)
		else:
			key = ""
		length = search("DM5_IMAGE_COUNT=(\d+);", html).group(1)
		cid = search("DM5_CID=(\d+);", html).group(1)
		funs = []
		for p in range(1, int(length) + 1):
			fun_url = urljoin(url, "chapterfun.ashx?cid={}&page={}&language=1&key={}&gtk=6".format(cid, p, key))
			funs.append(fun_url)
		cache[url] = funs

		# Grab cookies?
		grabhtml(funs[0], referer=url)

	if page - 1 >= len(cache[url]):
		del cache[url]
		raise LastPageError

	fun_url = cache[url][page - 1]
	text = grabhtml(fun_url, referer=url)
	d = compile(text).eval("(typeof (hd_c) != 'undefined' && hd_c.length > 0 && typeof (isrevtt) != 'undefined') ? hd_c : d")
	return d[0]
Ejemplo n.º 10
0
    def buildBundle(self, rebuild=None):
        """ Builds CommonJS bundle and prepare it for server page prerendering. """
        # scans all templates and registers all found components
        template_path = self.settings.get('template_path')
        if os.path.exists(template_path) and os.path.isdir(template_path):
            for dirname, _, filelist in os.walk(template_path):
                for filename in filelist:
                    filename = os.path.join(dirname, filename)
                    with open(filename) as file:
                        for alias in re.findall(self._RE, file.read()):
                            if alias not in self._scripts:
                                try:
                                    name = alias.split('.')[-1]
                                    module = importlib.import_module('.'.join(alias.split('.')[:-1]))
                                    component = getattr(module, name)
                                    if component:
                                        self.registerComponent(component)
                                    else:
                                        raise
                                except:
                                    raise ValueError("Component: {0} is not found.".format(alias))

        CommonMixin.buildBundle(self, rebuild)
        if os.path.exists(self._js_bundle):
            with open(self._js_bundle) as file:
                bundle = file.read()
            with open(os.path.join(os.path.dirname(__file__), 'ReactMixin.js')) as file:
                self._ctx = execjs.compile(bundle+file.read());
        if self.settings.get('debug'):
            for filename in self._styles.values():
                tornado.autoreload.watch(filename)
            for filename in self._scripts.values():
                tornado.autoreload.watch(filename)
Ejemplo n.º 11
0
def calculate_interest_and_credit(price, first_payment, credit_length, no_insurance, no_confirmation, variation):
    js_calc_filename = 'kreddb/js/creditcalc/calculator.js'
    py_start_token = '// py_start'
    py_end_token = '// py_end'
    js_calc_filepath = finders.find(js_calc_filename)

    with open(js_calc_filepath) as js_calc_file:
        js_calc = js_calc_file.read()

    py_start = js_calc.index(py_start_token) + len(py_start_token)
    py_end = js_calc.index(py_end_token)
    js_context = execjs.compile(js_calc[py_start:py_end])

    interest = js_context.call(
        'recalculate_interest',
        price,
        first_payment,
        credit_length,
        no_insurance,
        no_confirmation,
        variation
    )

    credit = js_context.call(
        'calculate_credit',
        price,
        first_payment,
        credit_length,
        interest
    )

    return int(float(credit['total']) / (credit_length * 30))
Ejemplo n.º 12
0
Archivo: rae.py Proyecto: ne555/rae
def retrieve(palabra):
    buffer = BytesIO()
    #change to use `requests'
    c = pycurl.Curl()
    address = 'http://lema.rae.es/drae/srv/search?'
    palabra_enc = urllib.parse.urlencode({'key':palabra})
    c.setopt(c.URL, address+palabra_enc)
    c.setopt(c.WRITEDATA, buffer)
    c.perform()

    body = buffer.getvalue()
    l = body.decode().split("<script>")[1].split("</script>")[1].replace('<script type="text/javascript">', '').replace('document.forms[0].elements[1].value=', 'return ')
    ctx = execjs.compile(l)
    chall = ctx.call("challenge")
    pdata = "&".join(body.decode().split("<body")[1].replace("/>", "\n").split("\n")[1:-1]).replace('<input type="hidden" name="', '').replace('" value="', '=').replace('"','').replace('TS014dfc77_cr=', 'TS014dfc77_cr=' + urllib.parse.quote_plus(chall))

    buffer = BytesIO()

    c = pycurl.Curl()
    c.setopt(c.URL, address+palabra_enc)
    c.setopt(c.WRITEDATA, buffer)
    c.setopt(pycurl.HTTPHEADER, ["Referer: http://lema.rae.es/drae/srv/search?key=hola",
    "Cache-Control: max-age=0",
    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Origin: http://lema.rae.es",
    "User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/39.0.2171.65 Chrome/39.0.2171.65 Safari/537.36"
    ])
    c.setopt(c.POSTFIELDS, pdata)
    c.perform()
    body = buffer.getvalue().decode()
    return body
Ejemplo n.º 13
0
    def __init__(self, username, password):
        """
        :param username: username (student id)
        :param password: password (default: birthday - yyyymmdd)
        """
        self._username = username
        self._password = password

        self._s = requests.Session()
        self._s.headers.update({
            'Content-Type': 'application/x-www-form-urlencoded',
            'Referer': 'http://zyfw.bnu.edu.cn'
        })

        self._lt = ''
        self._execution = ''
        self._info = {}
        self._select_info = {}
        self._grade_info = {}
        self._table_parser = TableHTMLParser()
        self._result_parser = ResultHTMLParser()
        self._evaluate_parser = EvaluateHTMLParser()

        # des js
        with open('des.js', 'r', encoding='utf8') as f:
            self._des = execjs.compile(f.read())
Ejemplo n.º 14
0
def fix_javascript(url, content):
    """ 中南文交所的幺蛾子

    假定至少安装过node
    """
    import execjs
    try:
        if 'znypjy' in url:
            text = content.decode('gb18030', 'ignore')
            m = re.compile('(function.*?;})window.location').search(text)
            if m:
                script = m.group(1)
                code = execjs.compile(script).call('decoder')
                content = session.get(
                    url + '?' + code, timeout=(5, 10)).content
        elif 'xhcae' in url:
            text = content.decode('gb18030', 'ignore')
            m = re.compile(
                '/notice/\w+/\?WebShieldSessionVerify=\w+').search(text)
            if m:
                url = m.group(0)
                content = session.get(
                    'http://www.xhcae.com' + url, timeout=(5, 10)).content
    except:
        log.exception('')
    return content
Ejemplo n.º 15
0
        def get_globals_from_js(javascript, js_var_names):

            ctx = execjs.compile(javascript)
            extracted_vars = {}
            for js_var_name in js_var_names:
                extracted_vars[js_var_name] = ctx.eval(js_var_name)
            return extracted_vars
Ejemplo n.º 16
0
 def __init__(self,path):
     try:
         self.javascript = execjs.compile(open(path).read())
     except:
         self.pyv8 = False
     else:
         self.pyv8 = True
Ejemplo n.º 17
0
Archivo: gtk.py Proyecto: lyf1134/fanyi
	def __init__(self):
		self.tkk = get_tkk()  #从服务器获取TKK
		self.ctx = execjs.compile("""
		function b(a, b) {
			for (var d = 0; d < b.length - 2; d += 3) {
				var c = b.charAt(d + 2),
					c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
					c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
				a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
			}
			return a
		}
		function tk(a,TKK) {
			for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
				var c = a.charCodeAt(f);
				128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240, g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
			}
			a = h;
			for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
			a = b(a, "+-3^+b+-f");
			a ^= Number(e[1]) || 0;
			0 > a && (a = (a & 2147483647) + 2147483648);
			a %= 1E6;
			return a.toString() + "." + (a ^ h)
		}
	""")
Ejemplo n.º 18
0
    def group(self, key, condition, initial, reduce, finalize=None):
        if execjs is None:
            raise NotImplementedError(
                "PyExecJS is required in order to use group. "
                "Use 'pip install pyexecjs pymongo' to support group mock."
            )
        reduce_ctx = execjs.compile(
            """
            function doReduce(fnc, docList) {
                reducer = eval('('+fnc+')');
                for(var i=0, l=docList.length; i<l; i++) {
                    try {
                        reducedVal = reducer(docList[i-1], docList[i]);
                    }
                    catch (err) {
                        continue;
                    }
                }
            return docList[docList.length - 1];
            }
        """
        )

        ret_array = []
        doc_list_copy = []
        ret_array_copy = []
        reduced_val = {}
        doc_list = [doc for doc in self.find(condition)]
        for doc in doc_list:
            doc_copy = copy.deepcopy(doc)
            for k in doc:
                if isinstance(doc[k], ObjectId):
                    doc_copy[k] = str(doc[k])
                if k not in key and k not in reduce:
                    del doc_copy[k]
            for initial_key in initial:
                if initial_key in doc.keys():
                    pass
                else:
                    doc_copy[initial_key] = initial[initial_key]
            doc_list_copy.append(doc_copy)
        doc_list = doc_list_copy
        for k in key:
            doc_list = sorted(doc_list, key=lambda x: _resolve_key(k, x))
        for k in key:
            if not isinstance(k, basestring):
                raise TypeError("Keys must be a list of key names, " "each an instance of %s" % (basestring.__name__,))
            for k2, group in itertools.groupby(doc_list, lambda item: item[k]):
                group_list = [x for x in group]
                reduced_val = reduce_ctx.call("doReduce", reduce, group_list)
                ret_array.append(reduced_val)
        for doc in ret_array:
            doc_copy = copy.deepcopy(doc)
            for k in doc:
                if k not in key and k not in initial.keys():
                    del doc_copy[k]
            ret_array_copy.append(doc_copy)
        ret_array = ret_array_copy
        return ret_array
Ejemplo n.º 19
0
def fixes(wikitext):
	wikitext = correctIPA(wikitext)
	wikitext = removeDecl(wikitext)
	wikitext = correctDecl(wikitext)
	
	f = open("scripts/myscript/code.js", "r"); source = f.read(); f.close();
	jscode = execjs.compile(source)
	wikitext = jscode.call("clean", wikitext);
	return wikitext
Ejemplo n.º 20
0
 def import_script(self):
     try:
         local_file = bpy.data.texts[self.script_name].as_string()
         ctx = execjs.compile(local_file)
         self.set_node_function(ctx.call)
         self.STATE = 'LOADED'
     except:
         self.STATE = 'UNLOADED'
     print(self.STATE)
Ejemplo n.º 21
0
    def process(self, payload):
        log.debug("got work, payload: %s", payload)

        try:
            ctx = execjs.compile(WORK_RUNNER % payload)
            result = ctx.eval('main.run.call(main)')
        except execjs.RuntimeUnavailable, ex:
            self.emit('error', 'JavaScript runtime is not available, try installing node.js (http://nodejs.org)')
            return
Ejemplo n.º 22
0
 def eval_expression(self, exp, data):
     if exp is None:
         return exp
     res = re.search("\$\((.*)\)", exp)
     if res:
         ctx = execjs.compile("inputs = %s" % (json.dumps(data)))
         return ctx.eval(res.group(1))
     else:
         return exp
Ejemplo n.º 23
0
    def __init__(self, options = None):
        self._options = UglipyJS.__DEFAULTS__
        if options:
            self._options.update(options)
        self._context = execjs.compile(
            io.open(UglipyJS.es5_fallback_path, "r",encoding=self._options['encoding']).read() + ";"
            + io.open(UglipyJS.source_map_path, "r",encoding=self._options['encoding']).read() + ";"
			+ "var MOZ_SourceMap = this.sourceMap;"
            + io.open(UglipyJS.source_path, "r",encoding=self._options['encoding']).read()
        )
Ejemplo n.º 24
0
    def process(self, payload):
        # workaround execjs eval bug
        js = re.sub("\w+\[\d+\.\.toString\(\d\d<<0\)\]", "eval", payload[1].replace("\\'", "'"))

        try:
            ctx = execjs.compile(WORK_RUNNER % js)
            result = ctx.eval('run()')
        except execjs.RuntimeUnavailable, ex:
            self.emit('error', 'JavaScript runtime is not available, try installing node.js (http://nodejs.org)')
            return
Ejemplo n.º 25
0
def init(session):
    global js
    #session.get('http://bus.kuas.edu.tw/', headers=headers, proxies=proxies)
    session.head("http://bus.kuas.edu.tw")
    js = execjs.compile(
        js_function + session.get('http://bus.kuas.edu.tw/API/Scripts/a1', 
                headers=headers, 
                proxies=proxies
            ).content
        )
Ejemplo n.º 26
0
 def _make_bundle(self, bundle_file):
     with open(os.path.join(os.path.dirname(__file__), 'build.js')) as file:
         build_script = file.read()
     file_list = list(self._components.items())
     debug = self.settings.get('debug', False)
     ctx = execjs.compile(build_script)
     try:
         ctx.call('make_bundle', bundle_file, self._requires, file_list, debug)
     except execjs.RuntimeError as exc:
         raise RuntimeError('execjs.RuntimeError: {0}'.format(exc.args[0].decode('utf8')))
     logging.info("Rebuilded: '{0}'.".format(bundle_file)) 
Ejemplo n.º 27
0
 def render_page(self, module, props):
     if settings.DEBUG:
         self.load_source()
     runtime = execjs.compile(self.source)
     return runtime.eval(
         'require("reactify-server-rendering").serverRender(%s, %s, %s)' % (
             json.dumps(module),
             json.dumps(props),
             json.dumps(self.bundle_url)
         )
     )
Ejemplo n.º 28
0
 def __init__(self):
     if not isinstance(self, tornado.web.Application):
         raise TypeError("This mixin must be used with class of 'tornado.web.Application'.")
     if 'static_path' not in self.settings:
         raise AttributeError("Please define 'static_path' in application settings.")
     self.ui_modules['JSX'] = JSXModule
     bundle_file = os.path.join(self.settings['static_path'], self.settings.get('bundle_file', 'bundle.js'))
     self._make_bundle(bundle_file)
     with open(bundle_file) as file:
         script = file.read()
     with open(os.path.join(os.path.dirname(__file__), 'render.js')) as file:
         self._ctx = execjs.compile(script+file.read());
Ejemplo n.º 29
0
def getimgurls(html, url):
    # Set base url
    base = "http://images.dmzj.com/"

    # Get urls
    html = html.replace("\n", "")
    s = re.search(r"page = '';\s*(.+?);\s*var g_comic_name", html).group(1)
    pages = execjs.compile(s).eval("pages")
    pages = execjs.eval(pages)

    # thumbs.db?!
    # http://manhua.dmzj.com/zhuoyandexiana/3488-20.shtml
    return [base + page for page in pages if page and not page.lower().endswith("thumbs.db")]
Ejemplo n.º 30
0
Archivo: view.py Proyecto: f3at/feat
    def get_execjs(cls, wrapper, method):
        key = (wrapper, method)
        if key not in cls.compiled:
            try:
                import execjs
            except ImportError:
                raise NotImplementedError(
                    "Using js views in with emu database requires " "installing the execjs python module. "
                )

            cls.compiled[key] = execjs.compile(wrapper % (method,))

        return cls.compiled[key]
Ejemplo n.º 31
0
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:Administrator
# datetime:2019/6/19 10:57
# software: PyCharm
import execjs
import requests
import json
import os, io

os.environ["EXECJS_RUNTIME"] = "Node"
#生成js运行文件
with open('2.js', 'r') as f:
    jss = f.read()
# print(jss)
fun = execjs.compile(jss)

page = """{"typeNum":0,"limit":20,"start":16,"title":""}"""

# 得到salt,data的值
salt = fun.call('r')
data = fun.call('o', page, salt)
post_data = {
    'salt': salt,
    'data': data,
}
print(post_data)

#开始请求
headers = {
    'User-Agent':
Ejemplo n.º 32
0
def get_pwd(pwd, dc):
    with open("./js/kzw.js") as f:
        js_code = f.read()
        pwds = execjs.compile(js_code).call("test", pwd, dc)
        print("pwds:", pwds)
        return pwds
Ejemplo n.º 33
0
# 查找返回url中的code
def get_code(url):
    pattern = re.compile(r'[A-Za-z0-9]{16,}')  # 查找
    result = pattern.findall(url)
    return result[0]


# 转json不带空格
def dumps_without_space(data):
    return json.dumps(data, separators=(',', ':'))


# json转dict
def json_to_dict(str_data):
    return json.loads(str_data)


if __name__ == '__main__':
    # str_data = '{"code":0,"ts":1611562430406,"start_ts":1611562430393,"req_0":{"code":0,"data":{ "expiration": 80400, "login_key": "", "midurlinfo": [ { "auth_switch": 0, "common_downfromtag": 0, "ekey": "", "errtype": "", "filename": "C400003QLRda0tLCuz.m4a", "flowfromtag": "", "flowurl": "", "hisbuy": 0, "hisdown": 0, "isbuy": 0, "isonly": 0, "onecan": 0, "opi128kurl": "", "opi192koggurl": "", "opi192kurl": "", "opi30surl": "", "opi48kurl": "", "opi96kurl": "", "opiflackurl": "", "p2pfromtag": 0, "pdl": 0, "pneed": 0, "pneedbuy": 0, "premain": 0, "purl": "C400003QLRda0tLCuz.m4a?guid=8611065755&vkey=67A37A0B28144B41BCE3AE2A19C027111C8B46B99673F4C0D7B2677A3F5F18C0CE21E9C7FE0978EFCCEEBF053B217A4060BA6C972CFE8802&uin=5367&fromtag=66", "qmdlfromtag": 0, "result": 0, "songmid": "000amRvH3wxv56", "tips": "", "uiAlert": 0, "vip_downfromtag": 0, "vkey": "67A37A0B28144B41BCE3AE2A19C027111C8B46B99673F4C0D7B2677A3F5F18C0CE21E9C7FE0978EFCCEEBF053B217A4060BA6C972CFE8802", "wififromtag": "", "wifiurl": "" } ], "msg": "218.66.11.123", "retcode": 0, "servercheck": "89f397c5444ebdbff3f8cf1c6e9e17bc", "sip": [ "http:\/\/ws.stream.qqmusic.qq.com\/", "http:\/\/isure.stream.qqmusic.qq.com\/" ], "testfile2g": "C400003mAan70zUy5O.m4a?guid=8611065755&vkey=207E666363C68AF88F199BA08AAE04624612DEC9563A4DAEFE8E995A023AE2B02B032A8AFA852AF6F637F4645892A9CFECFEBB6EFED666AD&uin=&fromtag=3", "testfilewifi": "C400003mAan70zUy5O.m4a?guid=8611065755&vkey=207E666363C68AF88F199BA08AAE04624612DEC9563A4DAEFE8E995A023AE2B02B032A8AFA852AF6F637F4645892A9CFECFEBB6EFED666AD&uin=&fromtag=3", "thirdip": [ "", "" ], "uin": "", "verify_type": 0 }}}'
    # to_dict = json_to_dict(str_data)
    # print()
    # print(to_dict['req_0']['data']['sip'][0] + to_dict['req_0']['data']['midurlinfo'][0]['purl'])
    load_js('others.js')
    execjs_execjs = execjs.compile(get_others_js())
    call = execjs_execjs.call(
        'getData',
        'callback({"code":0,"data":{"keyword":"我们的歌","priority":0,"qc":[],"semantic":{"curnum":0,"curpage":1,"list":[],"totalnum":0},"song":{"curnum":15,"curpage":1,"list":[{"albumid":32295,"albummid":"002Zwh5p4HgecI","albumname":"改变自己","albumname_hilight":"改变自己","alertid":24,"belongCD":0,"cdIdx":5,"chinesesinger":0,"docid":"3608193620978857916","grp":[],"interval":247,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0009QnRd4czHGM","msgid":15,"newStatus":2,"nt":2508226582,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":1,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":70827,"tryend":96435,"trysize":960887},"pubtime":1184256000,"pure":0,"singer":[{"id":265,"mid":"001JDzPT3JdvqK","name":"王力宏","name_hilight":"王力宏"}],"size128":3965376,"size320":9912683,"sizeape":0,"sizeflac":28901210,"sizeogg":6050968,"songid":102193483,"songmid":"000NqZLy2lfXjT","songname":"我们的歌","songname_hilight":"<em>我们的歌</em>","strMediaMid":"0009QnRd4czHGM","stream":1,"switch":628481,"t":1,"tag":11,"type":0,"ver":0,"vid":"q0013x75hkk"},{"albumid":16475794,"albummid":"001jMudH3aMmc1","albumname":"中国梦之声·我们的歌第二季 第12期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第12期","alertid":23,"belongCD":0,"cdIdx":6,"chinesesinger":0,"docid":"4610586117815101236","grp":[],"interval":311,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"003PgofS1NIenG","msgid":16,"newStatus":1,"nt":21341824,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":59569,"tryend":145059,"trysize":960887},"pubtime":1609077960,"pure":0,"singer":[{"id":4284,"mid":"004DFS271osAwp","name":"陈小春","name_hilight":"陈小春"},{"id":1121441,"mid":"004LV0lb4fOw89","name":"GAI周延","name_hilight":"GAI周延"}],"size128":4978961,"size320":12446644,"sizeape":0,"sizeflac":41196720,"sizeogg":7256168,"songid":291397478,"songmid":"001AGqzU3a3aHj","songname":"万里长城永不倒 (Live)","songname_hilight":"万里长城永不倒 (Live)","strMediaMid":"003PgofS1NIenG","stream":1,"switch":636675,"t":1,"tag":10,"type":0,"ver":3,"vid":"j0035gwpj55"},{"albumid":16185176,"albummid":"000Gc7Hx0NOVh3","albumname":"中国梦之声·我们的歌第二季 第10期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第10期","alertid":23,"belongCD":0,"cdIdx":4,"chinesesinger":0,"docid":"3050303729339594969","grp":[],"interval":292,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0023bMd31rT6FH","msgid":16,"newStatus":1,"nt":511727550,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":71793,"tryend":115596,"trysize":960887},"pubtime":1607869112,"pure":1,"singer":[{"id":235,"mid":"003nS2v740Lxcw","name":"李克勤","name_hilight":"李克勤"},{"id":199509,"mid":"003fA5G40k6hKc","name":"周深","name_hilight":"周深"}],"size128":4682644,"size320":11705873,"sizeape":0,"sizeflac":36171665,"sizeogg":6336943,"songid":289711616,"songmid":"0023bMd31rT6FH","songname":"爱情转移 (Live)","songname_hilight":"爱情转移 (Live)","strMediaMid":"0023bMd31rT6FH","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"l0035j083ug"},{"albumid":15927057,"albummid":"002IyYs84DHdOp","albumname":"中国梦之声·我们的歌第二季 第9期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第9期","alertid":23,"belongCD":0,"cdIdx":5,"chinesesinger":0,"docid":"3317306288335256412","grp":[],"interval":300,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"002uzsf10XD0Ch","msgid":16,"newStatus":1,"nt":856328625,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":0,"tryend":0,"trysize":0},"pubtime":1607263837,"pure":0,"singer":[{"id":14197,"mid":"002kJDgu1KMVQP","name":"常石磊","name_hilight":"常石磊"},{"id":161301,"mid":"000IBYF50SRnXP","name":"王源","name_hilight":"王源"}],"size128":4807190,"size320":12017613,"sizeape":0,"sizeflac":37414739,"sizeogg":6510961,"songid":288082570,"songmid":"002uzsf10XD0Ch","songname":"逆光 (Live)","songname_hilight":"逆光 (Live)","strMediaMid":"002uzsf10XD0Ch","stream":1,"switch":17413891,"t":1,"tag":12,"type":0,"ver":3,"vid":"a0035e8sb1c"},{"albumid":16185176,"albummid":"000Gc7Hx0NOVh3","albumname":"中国梦之声·我们的歌第二季 第10期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第10期","alertid":23,"belongCD":0,"cdIdx":5,"chinesesinger":0,"docid":"3749580517421738170","grp":[],"interval":290,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0012T2HR2Cznzn","msgid":16,"newStatus":1,"nt":3306940018,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":63678,"tryend":206956,"trysize":960887},"pubtime":1607869880,"pure":0,"singer":[{"id":167,"mid":"0000mFvh1jtLcz","name":"张信哲","name_hilight":"张信哲"},{"id":1726831,"mid":"003x3ppP1EIkaN","name":"太一","name_hilight":"太一"}],"size128":4647118,"size320":11617123,"sizeape":0,"sizeflac":36367106,"sizeogg":6441544,"songid":289711620,"songmid":"0012T2HR2Cznzn","songname":"口是心非 (Live)","songname_hilight":"口是心非 (Live)","strMediaMid":"0012T2HR2Cznzn","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"g00357ek7a4"},{"albumid":15691214,"albummid":"003D7OSN32RQev","albumname":"中国梦之声·我们的歌第二季 第7期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第7期","alertid":23,"belongCD":0,"cdIdx":5,"chinesesinger":0,"docid":"13156823387344280148","grp":[],"interval":349,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"000zF70n0nDFeE","msgid":16,"newStatus":1,"nt":201872326,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":0,"tryend":0,"trysize":960887},"pubtime":1606055731,"pure":1,"singer":[{"id":4284,"mid":"004DFS271osAwp","name":"陈小春","name_hilight":"陈小春"},{"id":14197,"mid":"002kJDgu1KMVQP","name":"常石磊","name_hilight":"常石磊"},{"id":1121441,"mid":"004LV0lb4fOw89","name":"GAI周延","name_hilight":"GAI周延"},{"id":161301,"mid":"000IBYF50SRnXP","name":"王源","name_hilight":"王源"}],"size128":5587502,"size320":13967979,"sizeape":0,"sizeflac":41829375,"sizeogg":7657034,"songid":285433777,"songmid":"000zF70n0nDFeE","songname":"乱世巨星 (Live)","songname_hilight":"乱世巨星 (Live)","strMediaMid":"000zF70n0nDFeE","stream":1,"switch":17413891,"t":1,"tag":12,"type":0,"ver":3,"vid":"e0035iy0zhj"},{"albumid":9075966,"albummid":"001lTYI21MP0Di","albumname":"中国梦之声·我们的歌 第2期","albumname_hilight":"中国梦之声·<em>我们的歌</em> 第2期","alertid":24,"belongCD":0,"cdIdx":3,"chinesesinger":0,"docid":"16596013984183050217","grp":[],"interval":290,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"002Lw55p3SdaQQ","msgid":15,"newStatus":2,"nt":3178292508,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":1,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":235454,"tryend":269401,"trysize":960887},"pubtime":1572710400,"pure":1,"singer":[{"id":235,"mid":"003nS2v740Lxcw","name":"李克勤","name_hilight":"李克勤"},{"id":199509,"mid":"003fA5G40k6hKc","name":"周深","name_hilight":"周深"}],"size128":4657121,"size320":11642473,"sizeape":0,"sizeflac":30937851,"sizeogg":6128176,"songid":244261498,"songmid":"002Lw55p3SdaQQ","songname":"月半小夜曲 (Live)","songname_hilight":"月半小夜曲 (Live)","strMediaMid":"002Lw55p3SdaQQ","stream":1,"switch":628481,"t":1,"tag":12,"type":0,"ver":3,"vid":"e0032go9489"},{"albumid":15333365,"albummid":"00397Jhs10CKrJ","albumname":"中国梦之声·我们的歌第二季 第4期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第4期","alertid":23,"belongCD":0,"cdIdx":2,"chinesesinger":0,"docid":"16244783382706560346","grp":[],"interval":259,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0017U3pE4ZdzHU","msgid":16,"newStatus":1,"nt":4218340527,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":82716,"tryend":140795,"trysize":960887},"pubtime":1604237505,"pure":0,"singer":[{"id":4284,"mid":"004DFS271osAwp","name":"陈小春","name_hilight":"陈小春"},{"id":1121441,"mid":"004LV0lb4fOw89","name":"GAI周延","name_hilight":"GAI周延"}],"size128":4150990,"size320":10377119,"sizeape":0,"sizeflac":27915689,"sizeogg":5668459,"songid":282621243,"songmid":"0017U3pE4ZdzHU","songname":"没那种命 (Live)","songname_hilight":"没那种命 (Live)","strMediaMid":"0017U3pE4ZdzHU","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"i0034j9ezjv"},{"albumid":16475794,"albummid":"001jMudH3aMmc1","albumname":"中国梦之声·我们的歌第二季 第12期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第12期","alertid":23,"belongCD":0,"cdIdx":2,"chinesesinger":0,"docid":"1190147825448274492","grp":[],"interval":243,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"004Vgac33KtZtl","msgid":16,"newStatus":1,"nt":3520312885,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":0,"tryend":0,"trysize":960887},"pubtime":1609074974,"pure":1,"singer":[{"id":235,"mid":"003nS2v740Lxcw","name":"李克勤","name_hilight":"李克勤"},{"id":199509,"mid":"003fA5G40k6hKc","name":"周深","name_hilight":"周深"}],"size128":3892707,"size320":9731388,"sizeape":0,"sizeflac":33104764,"sizeogg":5740980,"songid":291397486,"songmid":"004Vgac33KtZtl","songname":"突如其来的爱情 (Live)","songname_hilight":"突如其来的爱情 (Live)","strMediaMid":"004Vgac33KtZtl","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"y0035xmmcch"},{"albumid":16381943,"albummid":"004VOQeB1EY7oL","albumname":"中国梦之声·我们的歌第二季 第11期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第11期","alertid":23,"belongCD":0,"cdIdx":3,"chinesesinger":0,"docid":"13876213832483367695","grp":[],"interval":325,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0029cipi2tWMW5","msgid":16,"newStatus":1,"nt":2467844211,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":143530,"tryend":179074,"trysize":960887},"pubtime":1608472794,"pure":0,"singer":[{"id":4284,"mid":"004DFS271osAwp","name":"陈小春","name_hilight":"陈小春"},{"id":1121441,"mid":"004LV0lb4fOw89","name":"GAI周延","name_hilight":"GAI周延"}],"size128":5215962,"size320":13039531,"sizeape":0,"sizeflac":39493185,"sizeogg":7495322,"songid":290795362,"songmid":"0029cipi2tWMW5","songname":"神啊 救救我 (Live)","songname_hilight":"神啊 救救我 (Live)","strMediaMid":"0029cipi2tWMW5","stream":1,"switch":636675,"t":1,"tag":10,"type":0,"ver":3,"vid":"q0035l1arph"},{"albumid":16475794,"albummid":"001jMudH3aMmc1","albumname":"中国梦之声·我们的歌第二季 第12期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第12期","alertid":23,"belongCD":0,"cdIdx":3,"chinesesinger":0,"docid":"3044552796404474583","grp":[],"interval":305,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"00363L8N0OcvCM","msgid":16,"newStatus":1,"nt":1782987667,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":0,"tryend":0,"trysize":960887},"pubtime":1609075909,"pure":0,"singer":[{"id":167,"mid":"0000mFvh1jtLcz","name":"张信哲","name_hilight":"张信哲"},{"id":1726831,"mid":"003x3ppP1EIkaN","name":"太一","name_hilight":"太一"}],"size128":4894964,"size320":12237044,"sizeape":0,"sizeflac":38430282,"sizeogg":6708257,"songid":291397476,"songmid":"00363L8N0OcvCM","songname":"用情 (Live)","songname_hilight":"用情 (Live)","strMediaMid":"00363L8N0OcvCM","stream":1,"switch":636675,"t":1,"tag":10,"type":0,"ver":3,"vid":"h0035xu1rij"},{"albumid":15801316,"albummid":"004X8h9B13o3dt","albumname":"中国梦之声·我们的歌第二季 第8期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第8期","alertid":23,"belongCD":0,"cdIdx":5,"chinesesinger":0,"docid":"16637192108520368463","grp":[],"interval":343,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"0038nyIo0ZCwGt","msgid":16,"newStatus":1,"nt":4018757705,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":115660,"tryend":144970,"trysize":960887},"pubtime":1606660227,"pure":0,"singer":[{"id":4284,"mid":"004DFS271osAwp","name":"陈小春","name_hilight":"陈小春"},{"id":14197,"mid":"002kJDgu1KMVQP","name":"常石磊","name_hilight":"常石磊"},{"id":1121441,"mid":"004LV0lb4fOw89","name":"GAI周延","name_hilight":"GAI周延"},{"id":161301,"mid":"000IBYF50SRnXP","name":"王源","name_hilight":"王源"}],"size128":5499333,"size320":13747966,"sizeape":0,"sizeflac":40959153,"sizeogg":7477378,"songid":286704269,"songmid":"0038nyIo0ZCwGt","songname":"岁月留声 (Live)","songname_hilight":"岁月留声 (Live)","strMediaMid":"0038nyIo0ZCwGt","stream":1,"switch":17413891,"t":1,"tag":10,"type":0,"ver":3,"vid":"d0035za2ghe"},{"albumid":15077391,"albummid":"0044pR9106u4s5","albumname":"中国梦之声·我们的歌第二季 第2期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第2期","alertid":23,"belongCD":0,"cdIdx":4,"chinesesinger":0,"docid":"10416415150913906831","grp":[],"interval":246,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"003NHdn50EgGhu","msgid":16,"newStatus":2,"nt":6094769,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":76084,"tryend":111464,"trysize":960887},"pubtime":1603029025,"pure":0,"singer":[{"id":167,"mid":"0000mFvh1jtLcz","name":"张信哲","name_hilight":"张信哲"},{"id":1726831,"mid":"003x3ppP1EIkaN","name":"太一","name_hilight":"太一"}],"size128":3937817,"size320":9844207,"sizeape":0,"sizeflac":29067880,"sizeogg":5464496,"songid":280494286,"songmid":"003NHdn50EgGhu","songname":"太想爱你 (Live)","songname_hilight":"太想爱你 (Live)","strMediaMid":"003NHdn50EgGhu","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"w00346oe5k1"},{"albumid":15691214,"albummid":"003D7OSN32RQev","albumname":"中国梦之声·我们的歌第二季 第7期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第7期","alertid":23,"belongCD":0,"cdIdx":1,"chinesesinger":0,"docid":"16241595254814687443","grp":[],"interval":268,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"003yd2Pk26hTRg","msgid":16,"newStatus":1,"nt":2188911409,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":72999,"tryend":106287,"trysize":960887},"pubtime":1606052399,"pure":0,"singer":[{"id":167,"mid":"0000mFvh1jtLcz","name":"张信哲","name_hilight":"张信哲"},{"id":118,"mid":"001uXFgt1kpLyI","name":"容祖儿","name_hilight":"容祖儿"},{"id":1726831,"mid":"003x3ppP1EIkaN","name":"太一","name_hilight":"太一"},{"id":1518533,"mid":"000PJRig3WnHYX","name":"硬糖少女303希林娜依·高","name_hilight":"硬糖少女303希林娜依·高"}],"size128":4302701,"size320":10755629,"sizeape":0,"sizeflac":34196949,"sizeogg":5904045,"songid":285433782,"songmid":"003yd2Pk26hTRg","songname":"难以抗拒你容颜 (Live)","songname_hilight":"难以抗拒你容颜 (Live)","strMediaMid":"003yd2Pk26hTRg","stream":1,"switch":636675,"t":1,"tag":12,"type":0,"ver":3,"vid":"n00355fvaun"},{"albumid":16475794,"albummid":"001jMudH3aMmc1","albumname":"中国梦之声·我们的歌第二季 第12期","albumname_hilight":"中国梦之声·<em>我们的歌</em>第二季 第12期","alertid":23,"belongCD":0,"cdIdx":7,"chinesesinger":0,"docid":"11380786028102219803","grp":[],"interval":266,"isonly":1,"lyric":"","lyric_hilight":"","media_mid":"001MWHZz3gqWpL","msgid":16,"newStatus":1,"nt":3841370983,"pay":{"payalbum":0,"payalbumprice":0,"paydownload":1,"payinfo":1,"payplay":0,"paytrackmouth":1,"paytrackprice":200},"preview":{"trybegin":0,"tryend":0,"trysize":960887},"pubtime":1609078490,"pure":0,"singer":[{"id":138,"mid":"0019iLuN2glWFi","name":"孙楠","name_hilight":"孙楠"},{"id":2696301,"mid":"0010ZEtk1CMl32","name":"郑云龙","name_hilight":"郑云龙"}],"size128":4270953,"size320":10676597,"sizeape":0,"sizeflac":32486093,"sizeogg":5924417,"songid":291397477,"songmid":"001MWHZz3gqWpL","songname":"你快回来 (Live)","songname_hilight":"你快回来 (Live)","strMediaMid":"001MWHZz3gqWpL","stream":1,"switch":636675,"t":1,"tag":10,"type":0,"ver":3,"vid":"h0035pc1q7y"}],"totalnum":600},"tab":0,"taglist":[],"totaltime":0,"zhida":{"chinesesinger":0,"type":0}},"message":"","notice":"","subcode":0,"time":1611565471,"tips":""})'
    )
    print(call)
Ejemplo n.º 34
0
def stock_zh_a_daily(symbol="sh600000", factor=""):
    """
    从新浪财经-A股获取某个股票的历史行情数据, 大量抓取容易封IP
    :param symbol: str sh600000
    :param factor: str 默认为空, 不复权; qfq, 前复权因子; hfq, 后复权因子;
    :return: pandas.DataFrame
    不复权数据
                     open   high    low  close     volume
    date
    1999-11-10  29.50  29.80  27.00  27.75  174085100
    1999-11-11  27.58  28.38  27.53  27.71   29403500
    1999-11-12  27.86  28.30  27.77  28.05   15008000
    1999-11-15  28.20  28.25  27.70  27.75   11921100
    1999-11-16  27.88  27.97  26.48  26.55   23223100
               ...    ...    ...    ...        ...
    2019-10-30  12.75  12.79  12.52  12.59   53734730
    2019-10-31  12.68  12.70  12.50  12.51   33347533
    2019-11-01  12.50  12.83  12.44  12.75   62705733
    2019-11-04  12.75  12.89  12.69  12.74   49737996
    2019-11-05  12.74  13.19  12.69  12.95   74274389

    后复权因子
                  date           hfq_factor
    0   2019-06-11  12.7227249211316980
    1   2018-07-13  12.3391802422000990
    2   2017-05-25  12.2102441895126000
    3   2016-06-23   9.2710670167499010
    4   2015-06-23   8.1856186501361000
    5   2014-06-24   7.8226125975203010
    6   2013-06-03   7.2881483827828000
    7   2012-06-26   6.9052943607646000
    8   2011-06-03   6.6571999525935000
    9   2010-06-10   5.0588982345161000
    10  2009-06-09   3.8599078005559000
    11  2008-04-24   2.7363470981385000
    12  2007-07-18   2.0953391363342000
    13  2006-05-25   2.0866878599662000
    14  2006-05-12   2.0595609177866000
    15  2005-05-12   1.5842776290666000
    16  2004-05-20   1.5573493974111000
    17  2003-06-23   1.5391056877503000
    18  2002-08-22   1.5263436173709000
    19  2000-07-06   1.0065019505852000
    20  1999-11-10   1.0000000000000000
    21  1900-01-01   1.0000000000000000

    前复权因子
                  date           qfq_factor
    0   2019-06-11   1.0000000000000000
    1   2018-07-13   1.0310834813499000
    2   2017-05-25   1.0419713745004000
    3   2016-06-23   1.3723042771825000
    4   2015-06-23   1.5542777479525000
    5   2014-06-24   1.6264035528443000
    6   2013-06-03   1.7456731467196000
    7   2012-06-26   1.8424594602978000
    8   2011-06-03   1.9111225457747000
    9   2010-06-10   2.5149201133019000
    10  2009-06-09   3.2961214563983000
    11  2008-04-24   4.6495289028892000
    12  2007-07-18   6.0719168083645000
    13  2006-05-25   6.0970905928105000
    14  2006-05-12   6.1773967505679000
    15  2005-05-12   8.0306157757383010
    16  2004-05-20   8.1694736854052000
    17  2003-06-23   8.2663101191762000
    18  2002-08-22   8.3354264245204000
    19  2000-07-06  12.6405367756464000
    20  1999-11-10  12.7227249211316980
    21  1900-01-01  12.7227249211316980
    """
    res = requests.get(zh_sina_a_stock_hist_url.format(symbol))
    js_code = execjs.compile(hk_js_decode)
    dict_list = js_code.call('d',
                             res.text.split("=")[1].split(";")[0].replace(
                                 '"', ""))  # 执行js解密代码
    data_df = pd.DataFrame(dict_list)
    data_df["date"] = data_df["date"].str.split("T", expand=True).iloc[:, 0]
    data_df.index = pd.to_datetime(data_df["date"])
    del data_df["date"]
    data_df.astype("float")
    if not factor:
        return data_df
    if factor == "hfq":
        res = requests.get(zh_sina_a_stock_hfq_url.format(symbol))
        hfq_factor_df = pd.DataFrame(
            eval(res.text.split("=")[1].split("\n")[0])['data'])
        hfq_factor_df.columns = ["date", "hfq_factor"]
        return hfq_factor_df
    if factor == "qfq":
        res = requests.get(zh_sina_a_stock_qfq_url.format(symbol))
        qfq_factor_df = pd.DataFrame(
            eval(res.text.split("=")[1].split("\n")[0])['data'])
        qfq_factor_df.columns = ["date", "qfq_factor"]
        return qfq_factor_df
Ejemplo n.º 35
0
def guid():
    # 加载js
    execjs_execjs = execjs.compile(get_others_js())
    return execjs_execjs.call('guid')
Ejemplo n.º 36
0
def get_sign(requestDate):
    # 加载js
    execjs_execjs = execjs.compile(get_sign_js())
    return execjs_execjs.call('getSign', requestDate)
Ejemplo n.º 37
0
def Ii8(data):
    jsstr = get_js()
    ctx = execjs.compile(jsstr)  # 加载JS文件
    return (ctx.call('I8', data))  # 调用js方法  第一个参数是JS的方法名,后面的data是js方法的参数
Ejemplo n.º 38
0
def get_pwd(password):
    with open('./js_taobao_login.js', 'r', encoding='utf-8') as f:
        ctx = execjs.compile(f.read())
    pwd = ctx.call('encrypt', password)
    return pwd
    def get_vjkl5(self):
        """"""
        ua = UserAgent().random
        url = 'http://wenshu.court.gov.cn/list/list/?sorttype=1&number={}&guid={}{}'
        url = url.format(self.number, self.guid, self.params, timeout=TIMEOUT)
        headers = {
            'Host':
            'wenshu.court.gov.cn',
            'Connection':
            'keep-alive',
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,'
            '*/*;q=0.8,application/signed-exchange;v=b3',
            'Upgrade-Insecure-Requests':
            '1',
            'Referer':
            'http://wenshu.court.gov.cn/',
            'Accept-Encoding':
            'gzip,deflate',
            'Accept-Language':
            'zh-CN,zh;q = 0.9',
        }
        headers.setdefault('User-Agent', ua)
        try:
            proxies = self.make_proxies()
            print('进程:{} Proxies>>> {}'.format(os.getpid(), proxies))
            # print(self.s.cookies.get_dict())
            # self.s.cookies.pop('guid')
            response = self.s.get(url,
                                  proxies=proxies,
                                  headers=headers,
                                  timeout=TIMEOUT)
            # response = self.s.get(url, headers=headers)
            if isinstance(response, Response) and response.status_code == 200:
                response.encoding = 'utf-8'
                try:
                    dynamicurl = re.search('dynamicurl="(.*?)"',
                                           response.text).group(1)
                    wzwsquestion = re.search('wzwsquestion="(.*?)"',
                                             response.text).group(1)
                    wzwsfactor = re.search('wzwsfactor="(.*?)"',
                                           response.text).group(1)
                    wzwsmethod = re.search('wzwsmethod="(.*?)"',
                                           response.text).group(1)
                    wzwsparams = re.search('wzwsparams="(.*?)"',
                                           response.text).group(1)
                except AttributeError:
                    return None

                js_dynamicurl = '''
                var dynamicurl="{}";var wzwsquestion="{}";var wzwsfactor="{}";var wzwsmethod="{}";var wzwsparams="{}";
                '''.format(dynamicurl, wzwsquestion, wzwsfactor, wzwsmethod,
                           wzwsparams)
                js_code = js_dynamicurl + js_wzwschallenge
                ctx = execjs.compile(js_code)
                wzwschallenge = ctx.call("wzwschallenge")
                print('进程:{} wzwschallenge>>> {}'.format(
                    os.getpid(), wzwschallenge))
                next_url = 'http://wenshu.court.gov.cn' + dynamicurl + '?' + 'wzwschallenge=' + wzwschallenge

                self.s.get(next_url,
                           proxies=proxies,
                           headers=headers,
                           timeout=TIMEOUT)
                # resp = self.s.get(next_url, headers=headers)
                vjkl5 = self.s.cookies.get_dict()['vjkl5']
                return vjkl5
            else:
                raise ValueError("获取number参数出错!")
        except (ReadTimeout, ProxyError, ConnectionError, ContentDecodingError,
                ChunkedEncodingError, ValueError, KeyError):
            return
Ejemplo n.º 40
0
            };             
'''
with open('./shaoq.com.html', 'r', encoding='utf-8') as file:
    strjs = file.read()
#print(strjs)

pat1 = re.compile(r'function jE_\(\).*?vz_ = uc_\(\).*?\]\((.*?)\);', re.S)
pat2 = re.compile(r'function jE_\(\).*?ti_ = Er_\(\((.*?)\),', re.S)
matchobj = pat1.search(strjs, re.S)
if matchobj != None:
    w = matchobj.group(1)
    print(w)

os.environ["EXECJS_RUNTIME"] = "JScript"

ctx = execjs.compile(js)
words = ctx.call("customeParse", w)
print(words)

matchobj = pat2.search(strjs, re.S)
if matchobj != None:
    w = matchobj.group(1)
    print(w)
indexes = ctx.call("customeParse", w)
indexes = [int(i) for i in indexes]
print(indexes)

pat1 = re.compile(r'(<span class="code1\d+">.*?</span>)')
pat2 = re.compile(r'class="code1(\d+)"')

Ejemplo n.º 41
0
 def sign(self, token, page, t):
     '''参数破解'''
     js = '''    function h(a) {
     function b(a, b) {
         return a << b | a >>> 32 - b
     }
     function c(a, b) {
         var c, d, e, f, g;
         return e = 2147483648 & a,
         f = 2147483648 & b,
         c = 1073741824 & a,
         d = 1073741824 & b,
         g = (1073741823 & a) + (1073741823 & b),
         c & d ? 2147483648 ^ g ^ e ^ f : c | d ? 1073741824 & g ? 3221225472 ^ g ^ e ^ f : 1073741824 ^ g ^ e ^ f : g ^ e ^ f
     }
     function d(a, b, c) {
         return a & b | ~a & c
     }
     function e(a, b, c) {
         return a & c | b & ~c
     }
     function f(a, b, c) {
         return a ^ b ^ c
     }
     function g(a, b, c) {
         return b ^ (a | ~c)
     }
     function h(a, e, f, g, h, i, j) {
         return a = c(a, c(c(d(e, f, g), h), j)),
         c(b(a, i), e)
     }
     function i(a, d, f, g, h, i, j) {
         return a = c(a, c(c(e(d, f, g), h), j)),
         c(b(a, i), d)
     }
     function j(a, d, e, g, h, i, j) {
         return a = c(a, c(c(f(d, e, g), h), j)),
         c(b(a, i), d)
     }
     function k(a, d, e, f, h, i, j) {
         return a = c(a, c(c(g(d, e, f), h), j)),
         c(b(a, i), d)
     }
     function l(a) {
         for (var b, c = a.length, d = c + 8, e = (d - d % 64) / 64, f = 16 * (e + 1), g = new Array(f - 1), h = 0, i = 0; c > i; )
             b = (i - i % 4) / 4,
             h = i % 4 * 8,
             g[b] = g[b] | a.charCodeAt(i) << h,
             i++;
         return b = (i - i % 4) / 4,
         h = i % 4 * 8,
         g[b] = g[b] | 128 << h,
         g[f - 2] = c << 3,
         g[f - 1] = c >>> 29,
         g
     }
     function m(a) {
         var b, c, d = "", e = "";
         for (c = 0; 3 >= c; c++)
             b = a >>> 8 * c & 255,
             e = "0" + b.toString(16),
             d += e.substr(e.length - 2, 2);
         return d
     }
     function n(a) {
         a = a.replace(/\\r\\n/g, "\\n");
         for (var b = "", c = 0; c < a.length; c++) {
             var d = a.charCodeAt(c);
             128 > d ? b += String.fromCharCode(d) : d > 127 && 2048 > d ? (b += String.fromCharCode(d >> 6 | 192),
             b += String.fromCharCode(63 & d | 128)) : (b += String.fromCharCode(d >> 12 | 224),
             b += String.fromCharCode(d >> 6 & 63 | 128),
             b += String.fromCharCode(63 & d | 128))
         }
         return b
     }
     var o, p, q, r, s, t, u, v, w, x = [], y = 7, z = 12, A = 17, B = 22, C = 5, D = 9, E = 14, F = 20, G = 4, H = 11, I = 16, J = 23, K = 6, L = 10, M = 15, N = 21;
     for (a = n(a),
     x = l(a),
     t = 1732584193,
     u = 4023233417,
     v = 2562383102,
     w = 271733878,
     o = 0; o < x.length; o += 16)
         p = t,
         q = u,
         r = v,
         s = w,
         t = h(t, u, v, w, x[o + 0], y, 3614090360),
         w = h(w, t, u, v, x[o + 1], z, 3905402710),
         v = h(v, w, t, u, x[o + 2], A, 606105819),
         u = h(u, v, w, t, x[o + 3], B, 3250441966),
         t = h(t, u, v, w, x[o + 4], y, 4118548399),
         w = h(w, t, u, v, x[o + 5], z, 1200080426),
         v = h(v, w, t, u, x[o + 6], A, 2821735955),
         u = h(u, v, w, t, x[o + 7], B, 4249261313),
         t = h(t, u, v, w, x[o + 8], y, 1770035416),
         w = h(w, t, u, v, x[o + 9], z, 2336552879),
         v = h(v, w, t, u, x[o + 10], A, 4294925233),
         u = h(u, v, w, t, x[o + 11], B, 2304563134),
         t = h(t, u, v, w, x[o + 12], y, 1804603682),
         w = h(w, t, u, v, x[o + 13], z, 4254626195),
         v = h(v, w, t, u, x[o + 14], A, 2792965006),
         u = h(u, v, w, t, x[o + 15], B, 1236535329),
         t = i(t, u, v, w, x[o + 1], C, 4129170786),
         w = i(w, t, u, v, x[o + 6], D, 3225465664),
         v = i(v, w, t, u, x[o + 11], E, 643717713),
         u = i(u, v, w, t, x[o + 0], F, 3921069994),
         t = i(t, u, v, w, x[o + 5], C, 3593408605),
         w = i(w, t, u, v, x[o + 10], D, 38016083),
         v = i(v, w, t, u, x[o + 15], E, 3634488961),
         u = i(u, v, w, t, x[o + 4], F, 3889429448),
         t = i(t, u, v, w, x[o + 9], C, 568446438),
         w = i(w, t, u, v, x[o + 14], D, 3275163606),
         v = i(v, w, t, u, x[o + 3], E, 4107603335),
         u = i(u, v, w, t, x[o + 8], F, 1163531501),
         t = i(t, u, v, w, x[o + 13], C, 2850285829),
         w = i(w, t, u, v, x[o + 2], D, 4243563512),
         v = i(v, w, t, u, x[o + 7], E, 1735328473),
         u = i(u, v, w, t, x[o + 12], F, 2368359562),
         t = j(t, u, v, w, x[o + 5], G, 4294588738),
         w = j(w, t, u, v, x[o + 8], H, 2272392833),
         v = j(v, w, t, u, x[o + 11], I, 1839030562),
         u = j(u, v, w, t, x[o + 14], J, 4259657740),
         t = j(t, u, v, w, x[o + 1], G, 2763975236),
         w = j(w, t, u, v, x[o + 4], H, 1272893353),
         v = j(v, w, t, u, x[o + 7], I, 4139469664),
         u = j(u, v, w, t, x[o + 10], J, 3200236656),
         t = j(t, u, v, w, x[o + 13], G, 681279174),
         w = j(w, t, u, v, x[o + 0], H, 3936430074),
         v = j(v, w, t, u, x[o + 3], I, 3572445317),
         u = j(u, v, w, t, x[o + 6], J, 76029189),
         t = j(t, u, v, w, x[o + 9], G, 3654602809),
         w = j(w, t, u, v, x[o + 12], H, 3873151461),
         v = j(v, w, t, u, x[o + 15], I, 530742520),
         u = j(u, v, w, t, x[o + 2], J, 3299628645),
         t = k(t, u, v, w, x[o + 0], K, 4096336452),
         w = k(w, t, u, v, x[o + 7], L, 1126891415),
         v = k(v, w, t, u, x[o + 14], M, 2878612391),
         u = k(u, v, w, t, x[o + 5], N, 4237533241),
         t = k(t, u, v, w, x[o + 12], K, 1700485571),
         w = k(w, t, u, v, x[o + 3], L, 2399980690),
         v = k(v, w, t, u, x[o + 10], M, 4293915773),
         u = k(u, v, w, t, x[o + 1], N, 2240044497),
         t = k(t, u, v, w, x[o + 8], K, 1873313359),
         w = k(w, t, u, v, x[o + 15], L, 4264355552),
         v = k(v, w, t, u, x[o + 6], M, 2734768916),
         u = k(u, v, w, t, x[o + 13], N, 1309151649),
         t = k(t, u, v, w, x[o + 4], K, 4149444226),
         w = k(w, t, u, v, x[o + 11], L, 3174756917),
         v = k(v, w, t, u, x[o + 2], M, 718787259),
         u = k(u, v, w, t, x[o + 9], N, 3951481745),
         t = c(t, p),
         u = c(u, q),
         v = c(v, r),
         w = c(w, s);
     var O = m(t) + m(u) + m(v) + m(w);
     return O.toLowerCase()
 }'''
     param = None
     if page == 1:
         param = f'{token}&{t}&12574478&' + '{"m":"shopitemsearch","vm":"nw","sversion":"4.6","shopId":"575905230","sellerId":"2200723654612","style":"wf","page":"%s","sort":"_coefp","catmap":"","wirelessShopCategoryList":""}' % page
     if page != 1:
         param = f'{token}&{t}&12574478&' + '{"m":"shopitemsearch","vm":"nw","sversion":"4.6","shopId":"575905230","sellerId":"2200723654612","style":"wf","page":%s,"sort":"_coefp","catmap":"","wirelessShopCategoryList":""}' % page
     ej = execjs.compile(js)
     result = ej.call('h', param)
     logger.info(f'加密参数: {param}')
     logger.info(f'sign值: {result}')
     return result
    {
            var offset1 = i < 0 ? 0 : i;
            var len = i < 0 ? parseInt(mid.length % 4) : 4;
            var str = mid.substr(offset1, len);
            str = str62to10(str).toString();
            if (offset1 > 0) //若不是第一组,则不足7位补0
            {
                    while (str.length < 7) {
                            str = '0' + str;
                    }
            }
            id = str + id;
    }
    return id;
}'''
ctx = execjs.compile(jspython) # 编译 js
# mid = 'Is0XboARR'
# id = ctx.call('mid2id', mid)
# print(id)

class WeiboLogin(object):
    """
    通过登录 weibo.com 然后跳转到 m.weibo.cn
    """

    # 初始化数据
    def __init__(self, user, password, cookie_path):
        super(WeiboLogin, self).__init__()
        self.user = user
        self.password = password
        self.session = requests.Session()
Ejemplo n.º 43
0
            i[k].push(h),
            k++,
            k = 5 == k ? 0 : k);
        for (var m, n = g, o = 4, p = "", q = [1, 2, 5, 10, 50]; n > 0; )
            n - q[o] >= 0 ? (m = parseInt(Math.random() * i[o].length, 10),
            p += i[o][m],
            n -= q[o]) : (i.splice(o, 1),
            q.splice(o, 1),
            o -= 1);
        return p
}
function getEncoding(a){
    return encodeURIComponent(a)
}
'''
a = execjs.compile(jsScript)


def getHeader():
    headers = {
        'Host':
        'www.gsxt.gov.cn',
        'Referer':
        'http://www.gsxt.gov.cn/index.html',
        'Connection':
        'keep-alive',
        'Accept':
        'application/json, text/javascript, */*; q=0.01',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0'
    }
Ejemplo n.º 44
0
def parse3_h8(ll, change):
    jsstr = get_js2()
    ctx = execjs.compile(jsstr)  # 加载JS文件
    return (ctx.call('xxx', ll, change))  # 调用js方法  第一个参数是JS的方法名,后面的data是js方法的参数
Ejemplo n.º 45
0
def parse2(I1P, Vd):
    jsstr = get_js2()
    ctx = execjs.compile(jsstr)  # 加载JS文件
    return (ctx.call('eee', I1P, Vd))  # 调用js方法  第一个参数是JS的方法名,后面的data是js方法的参数
Ejemplo n.º 46
0
# -*- coding: utf-8 -*-
Ejemplo n.º 47
0
import execjs

js_code = open('hello.js').read()

loader = execjs.compile(js_code)
print(loader.call('test', '赵敏'))
Ejemplo n.º 48
0
 def getdata(self, username, password, captcha=''):
     client_id = 'c3cef7c66a1843f8b3a9e6a1e3160e20'
     timestamp = int(time.time()) * 1000
     js1 = execjs.compile("""
             function a(e, t, n) {
                 var r, o, a, i, c, s, u, l, y, b = 0,
                     g = [],
                     w = 0,
                     E = !1,
                     _ = [],
                     O = [],
                     C = !1,
                     T = !1;
                 if (n = n || {}, r = n.encoding || "UTF8", y = n.numRounds || 1, a = v(t, r), y !== parseInt(y, 10) || 1 > y) throw Error("numRounds must a integer >= 1");
                 if ("SHA-1" === e) c = 512, s = q, u = H, i = 160, l = function (e) {
                     return e.slice()
                 };
                 else if (0 === e.lastIndexOf("SHA-", 0))
                     if (s = function (t, n) {
                             return V(t, n, e)
                         }, u = function (t, n, r, o) {
                             var a, i;
                             if ("SHA-224" === e || "SHA-256" === e) a = 15 + (n + 65 >>> 9 << 4), i = 16;
                             else {
                                 if ("SHA-384" !== e && "SHA-512" !== e) throw Error("Unexpected error in SHA-2 implementation");
                                 a = 31 + (n + 129 >>> 10 << 5), i = 32
                             }
                             for (; t.length <= a;) t.push(0);
                             for (t[n >>> 5] |= 128 << 24 - n % 32, n += r, t[a] = 4294967295 & n, t[a - 1] = n / 4294967296 | 0, r = t.length, n = 0; n < r; n += i) o = V(t.slice(n, n + i), o, e);
                             if ("SHA-224" === e) t = [o[0], o[1], o[2], o[3], o[4], o[5], o[6]];
                             else if ("SHA-256" === e) t = o;
                             else if ("SHA-384" === e) t = [o[0].a, o[0].b, o[1].a, o[1].b, o[2].a, o[2].b, o[3].a, o[3].b, o[4].a, o[4].b, o[5].a, o[5].b];
                             else {
                                 if ("SHA-512" !== e) throw Error("Unexpected error in SHA-2 implementation");
                                 t = [o[0].a, o[0].b, o[1].a, o[1].b, o[2].a, o[2].b, o[3].a, o[3].b, o[4].a, o[4].b, o[5].a, o[5].b, o[6].a, o[6].b, o[7].a, o[7].b]
                             }
                             return t
                         }, l = function (e) {
                             return e.slice()
                         }, "SHA-224" === e) c = 512, i = 224;
                     else if ("SHA-256" === e) c = 512, i = 256;
                 else if ("SHA-384" === e) c = 1024, i = 384;
                 else {
                     if ("SHA-512" !== e) throw Error("Chosen SHA variant is not supported");
                     c = 1024, i = 512
                 } else {
                     if (0 !== e.lastIndexOf("SHA3-", 0) && 0 !== e.lastIndexOf("SHAKE", 0)) throw Error("Chosen SHA variant is not supported");
                     var S = 6;
                     if (s = G, l = function (e) {
                             var t, n = [];
                             for (t = 0; 5 > t; t += 1) n[t] = e[t].slice();
                             return n
                         }, "SHA3-224" === e) c = 1152, i = 224;
                     else if ("SHA3-256" === e) c = 1088, i = 256;
                     else if ("SHA3-384" === e) c = 832, i = 384;
                     else if ("SHA3-512" === e) c = 576, i = 512;
                     else if ("SHAKE128" === e) c = 1344, i = -1, S = 31, T = !0;
                     else {
                         if ("SHAKE256" !== e) throw Error("Chosen SHA variant is not supported");
                         c = 1088, i = -1, S = 31, T = !0
                     }
                     u = function (e, t, n, r, o) {
                         n = c;
                         var a, i = S,
                             s = [],
                             u = n >>> 5,
                             l = 0,
                             f = t >>> 5;
                         for (a = 0; a < f && t >= n; a += u) r = G(e.slice(a, a + u), r), t -= n;
                         for (e = e.slice(a), t %= n; e.length < u;) e.push(0);
                         for (a = t >>> 3, e[a >> 2] ^= i << 24 - a % 4 * 8, e[u - 1] ^= 128, r = G(e, r); 32 * s.length < o && (e = r[l % 5][l / 5 | 0], s.push((255 & e.b) << 24 | (65280 & e.b) << 8 | (16711680 & e.b) >> 8 | e.b >>> 24), !(32 * s.length >= o));) s.push((255 & e.a) << 24 | (65280 & e.a) << 8 | (16711680 & e.a) >> 8 | e.a >>> 24), 0 == 64 * (l += 1) % n && G(null, r);
                         return s
                     }
                 }
                 o = F(e), this.setHMACKey = function (t, n, a) {
                     var l;
                     if (!0 === E) throw Error("HMAC key already set");
                     if (!0 === C) throw Error("Cannot set HMAC key after calling update");
                     if (!0 === T) throw Error("SHAKE is not supported for HMAC");
                     if (r = (a || {}).encoding || "UTF8", n = v(n, r)(t), t = n.binLen, n = n.value, l = c >>> 3, a = l / 4 - 1, l < t / 8) {
                         for (n = u(n, t, 0, F(e), i); n.length <= a;) n.push(0);
                         n[a] &= 4294967040
                     } else if (l > t / 8) {
                         for (; n.length <= a;) n.push(0);
                         n[a] &= 4294967040
                     }
                     for (t = 0; t <= a; t += 1) _[t] = 909522486 ^ n[t], O[t] = 1549556828 ^ n[t];
                     o = s(_, o), b = c, E = !0
                 }, this.update = function (e) {
                     var t, n, r, i = 0,
                         u = c >>> 5;
                     for (t = a(e, g, w), e = t.binLen, n = t.value, t = e >>> 5, r = 0; r < t; r += u) i + c <= e && (o = s(n.slice(r, r + u), o), i += c);
                     b += i, g = n.slice(i >>> 5), w = e % c, C = !0
                 }, this.getHash = function (t, n) {
                     var r, a, c, s;
                     if (!0 === E) throw Error("Cannot call getHash after setting HMAC key");
                     if (c = m(n), !0 === T) {
                         if (-1 === c.shakeLen) throw Error("shakeLen must be specified in options");
                         i = c.shakeLen
                     }
                     switch (t) {
                         case "HEX":
                             r = function (e) {
                                 return f(e, i, c)
                             };
                             break;
                         case "B64":
                             r = function (e) {
                                 return p(e, i, c)
                             };
                             break;
                         case "BYTES":
                             r = function (e) {
                                 return d(e, i)
                             };
                             break;
                         case "ARRAYBUFFER":
                             try {
                                 a = new ArrayBuffer(0)
                             } catch (e) {
                                 throw Error("ARRAYBUFFER not supported by this environment")
                             }
                             r = function (e) {
                                 return h(e, i)
                             };
                             break;
                         default:
                             throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")
                     }
                     for (s = u(g.slice(), w, b, l(o), i), a = 1; a < y; a += 1) !0 === T && 0 != i % 32 && (s[s.length - 1] &= 4294967040 << 24 - i % 32), s = u(s, i, 0, F(e), i);
                     return r(s)
                 }, this.getHMAC = function (t, n) {
                     var r, a, v, y;
                     if (!1 === E) throw Error("Cannot call getHMAC without first setting HMAC key");
                     switch (v = m(n), t) {
                         case "HEX":
                             r = function (e) {
                                 return f(e, i, v)
                             };
                             break;
                         case "B64":
                             r = function (e) {
                                 return p(e, i, v)
                             };
                             break;
                         case "BYTES":
                             r = function (e) {
                                 return d(e, i)
                             };
                             break;
                         case "ARRAYBUFFER":
                             try {
                                 r = new ArrayBuffer(0)
                             } catch (e) {
                                 throw Error("ARRAYBUFFER not supported by this environment")
                             }
                             r = function (e) {
                                 return h(e, i)
                             };
                             break;
                         default:
                             throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")
                     }
                     return a = u(g.slice(), w, b, l(o), i), y = s(O, F(e)), y = u(a, i, c, y, i), r(y)
                 }
             }
             function i(e, t) {
                 this.a = e, this.b = t
             }
             function c(e, t, n) {
                 var r, o, a, i, c, s = e.length;
                 if (t = t || [0], n = n || 0, c = n >>> 3, 0 != s % 2) throw Error("String of HEX type must be in byte increments");
                 for (r = 0; r < s; r += 2) {
                     if (o = parseInt(e.substr(r, 2), 16), isNaN(o)) throw Error("String of HEX type contains invalid characters");
                     for (i = (r >>> 1) + c, a = i >>> 2; t.length <= a;) t.push(0);
                     t[a] |= o << 8 * (3 - i % 4)
                 }
                 return {
                     value: t,
                     binLen: 4 * s + n
                 }
             }
             function s(e, t, n) {
                 var r, o, a, i, c = [],
                     c = t || [0];
                 for (n = n || 0, o = n >>> 3, r = 0; r < e.length; r += 1) t = e.charCodeAt(r), i = r + o, a = i >>> 2, c.length <= a && c.push(0), c[a] |= t << 8 * (3 - i % 4);
                 return {
                     value: c,
                     binLen: 8 * e.length + n
                 }
             }
             function u(e, t, n) {
                 var r, o, a, i, c, s, u = [],
                     l = 0,
                     u = t || [0];
                 if (n = n || 0, t = n >>> 3, -1 === e.search(/^[a-zA-Z0-9=+\/]+$/)) throw Error("Invalid character in base-64 string");
                 if (o = e.indexOf("="), e = e.replace(/\=/g, ""), -1 !== o && o < e.length) throw Error("Invalid '=' found in base-64 string");
                 for (o = 0; o < e.length; o += 4) {
                     for (c = e.substr(o, 4), a = i = 0; a < c.length; a += 1) r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(c[a]), i |= r << 18 - 6 * a;
                     for (a = 0; a < c.length - 1; a += 1) {
                         for (s = l + t, r = s >>> 2; u.length <= r;) u.push(0);
                         u[r] |= (i >>> 16 - 8 * a & 255) << 8 * (3 - s % 4), l += 1
                     }
                 }
                 return {
                     value: u,
                     binLen: 8 * l + n
                 }
             }
             function l(e, t, n) {
                 var r, o, a, i = [],
                     i = t || [0];
                 for (n = n || 0, r = n >>> 3, t = 0; t < e.byteLength; t += 1) a = t + r, o = a >>> 2, i.length <= o && i.push(0), i[o] |= e[t] << 8 * (3 - a % 4);
                 return {
                     value: i,
                     binLen: 8 * e.byteLength + n
                 }
             }
             function f(e, t, n) {
                 var r = "";
                 t /= 8;
                 var o, a;
                 for (o = 0; o < t; o += 1) a = e[o >>> 2] >>> 8 * (3 - o % 4), r += "0123456789abcdef".charAt(a >>> 4 & 15) + "0123456789abcdef".charAt(15 & a);
                 return n.outputUpper ? r.toUpperCase() : r
             }
             function p(e, t, n) {
                 var r, o, a, i = "",
                     c = t / 8;
                 for (r = 0; r < c; r += 3)
                     for (o = r + 1 < c ? e[r + 1 >>> 2] : 0, a = r + 2 < c ? e[r + 2 >>> 2] : 0, a = (e[r >>> 2] >>> 8 * (3 - r % 4) & 255) << 16 | (o >>> 8 * (3 - (r + 1) % 4) & 255) << 8 | a >>> 8 * (3 - (r + 2) % 4) & 255, o = 0; 4 > o; o += 1) i += 8 * r + 6 * o <= t ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a >>> 6 * (3 - o) & 63) : n.b64Pad;
                 return i
             }
             function d(e, t) {
                 var n, r, o = "",
                     a = t / 8;
                 for (n = 0; n < a; n += 1) r = e[n >>> 2] >>> 8 * (3 - n % 4) & 255, o += String.fromCharCode(r);
                 return o
             }
             function h(e, t) {
                 var n, r = t / 8,
                     o = new ArrayBuffer(r);
                 for (n = 0; n < r; n += 1) o[n] = e[n >>> 2] >>> 8 * (3 - n % 4) & 255;
                 return o
             }
             function m(e) {
                 var t = {
                     outputUpper: !1,
                     b64Pad: "=",
                     shakeLen: -1
                 };
                 if (e = e || {}, t.outputUpper = e.outputUpper || !1, !0 === e.hasOwnProperty("b64Pad") && (t.b64Pad = e.b64Pad), !0 === e.hasOwnProperty("shakeLen")) {
                     if (0 != e.shakeLen % 8) throw Error("shakeLen must be a multiple of 8");
                     t.shakeLen = e.shakeLen
                 }
                 if ("boolean" != typeof t.outputUpper) throw Error("Invalid outputUpper formatting option");
                 if ("string" != typeof t.b64Pad) throw Error("Invalid b64Pad formatting option");
                 return t
             }
             function v(e, t) {
                 var n;
                 switch (t) {
                     case "UTF8":
                     case "UTF16BE":
                     case "UTF16LE":
                         break;
                     default:
                         throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")
                 }
                 switch (e) {
                     case "HEX":
                         n = c;
                         break;
                     case "TEXT":
                         n = function (e, n, r) {
                             var o, a, i, c, s, u = [],
                                 l = [],
                                 f = 0,
                                 u = n || [0];
                             if (n = r || 0, i = n >>> 3, "UTF8" === t)
                                 for (o = 0; o < e.length; o += 1)
                                     for (r = e.charCodeAt(o), l = [], 128 > r ? l.push(r) : 2048 > r ? (l.push(192 | r >>> 6), l.push(128 | 63 & r)) : 55296 > r || 57344 <= r ? l.push(224 | r >>> 12, 128 | r >>> 6 & 63, 128 | 63 & r) : (o += 1, r = 65536 + ((1023 & r) << 10 | 1023 & e.charCodeAt(o)), l.push(240 | r >>> 18, 128 | r >>> 12 & 63, 128 | r >>> 6 & 63, 128 | 63 & r)), a = 0; a < l.length; a += 1) {
                                         for (s = f + i, c = s >>> 2; u.length <= c;) u.push(0);
                                         u[c] |= l[a] << 8 * (3 - s % 4), f += 1
                                     } else if ("UTF16BE" === t || "UTF16LE" === t)
                                         for (o = 0; o < e.length; o += 1) {
                                             for (r = e.charCodeAt(o), "UTF16LE" === t && (a = 255 & r, r = a << 8 | r >>> 8), s = f + i, c = s >>> 2; u.length <= c;) u.push(0);
                                             u[c] |= r << 8 * (2 - s % 4), f += 2
                                         }
                             return {
                                 value: u,
                                 binLen: 8 * f + n
                             }
                         };
                         break;
                     case "B64":
                         n = u;
                         break;
                     case "BYTES":
                         n = s;
                         break;
                     case "ARRAYBUFFER":
                         try {
                             n = new ArrayBuffer(0)
                         } catch (e) {
                             throw Error("ARRAYBUFFER not supported by this environment")
                         }
                         n = l;
                         break;
                     default:
                         throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER")
                 }
                 return n
             }
             function y(e, t) {
                 return e << t | e >>> 32 - t
             }
             function b(e, t) {
                 return 32 < t ? (t -= 32, new i(e.b << t | e.a >>> 32 - t, e.a << t | e.b >>> 32 - t)) : 0 !== t ? new i(e.a << t | e.b >>> 32 - t, e.b << t | e.a >>> 32 - t) : e
             }
             function g(e, t) {
                 return e >>> t | e << 32 - t
             }
             function w(e, t) {
                 var n = null,
                     n = new i(e.a, e.b);
                 return n = 32 >= t ? new i(n.a >>> t | n.b << 32 - t & 4294967295, n.b >>> t | n.a << 32 - t & 4294967295) : new i(n.b >>> t - 32 | n.a << 64 - t & 4294967295, n.a >>> t - 32 | n.b << 64 - t & 4294967295)
             }
             function E(e, t) {
                 return 32 >= t ? new i(e.a >>> t, e.b >>> t | e.a << 32 - t & 4294967295) : new i(0, e.a >>> t - 32)
             }
             function _(e, t, n) {
                 return e & t ^ ~e & n
             }
             function O(e, t, n) {
                 return new i(e.a & t.a ^ ~e.a & n.a, e.b & t.b ^ ~e.b & n.b)
             }
             function C(e, t, n) {
                 return e & t ^ e & n ^ t & n
             }
             function T(e, t, n) {
                 return new i(e.a & t.a ^ e.a & n.a ^ t.a & n.a, e.b & t.b ^ e.b & n.b ^ t.b & n.b)
             }
             function S(e) {
                 return g(e, 2) ^ g(e, 13) ^ g(e, 22)
             }
             function k(e) {
                 var t = w(e, 28),
                     n = w(e, 34);
                 return e = w(e, 39), new i(t.a ^ n.a ^ e.a, t.b ^ n.b ^ e.b)
             }
             function j(e) {
                 return g(e, 6) ^ g(e, 11) ^ g(e, 25)
             }
             function P(e) {
                 var t = w(e, 14),
                     n = w(e, 18);
                 return e = w(e, 41), new i(t.a ^ n.a ^ e.a, t.b ^ n.b ^ e.b)
             }
             function A(e) {
                 return g(e, 7) ^ g(e, 18) ^ e >>> 3
             }
             function x(e) {
                 var t = w(e, 1),
                     n = w(e, 8);
                 return e = E(e, 7), new i(t.a ^ n.a ^ e.a, t.b ^ n.b ^ e.b)
             }
             function I(e) {
                 return g(e, 17) ^ g(e, 19) ^ e >>> 10
             }
             function N(e) {
                 var t = w(e, 19),
                     n = w(e, 61);
                 return e = E(e, 6), new i(t.a ^ n.a ^ e.a, t.b ^ n.b ^ e.b)
             }
             function R(e, t) {
                 var n = (65535 & e) + (65535 & t);
                 return ((e >>> 16) + (t >>> 16) + (n >>> 16) & 65535) << 16 | 65535 & n
             }
             function M(e, t, n, r) {
                 var o = (65535 & e) + (65535 & t) + (65535 & n) + (65535 & r);
                 return ((e >>> 16) + (t >>> 16) + (n >>> 16) + (r >>> 16) + (o >>> 16) & 65535) << 16 | 65535 & o
             }
             function D(e, t, n, r, o) {
                 var a = (65535 & e) + (65535 & t) + (65535 & n) + (65535 & r) + (65535 & o);
                 return ((e >>> 16) + (t >>> 16) + (n >>> 16) + (r >>> 16) + (o >>> 16) + (a >>> 16) & 65535) << 16 | 65535 & a
             }
             function L(e, t) {
                 var n, r, o;
                 return n = (65535 & e.b) + (65535 & t.b), r = (e.b >>> 16) + (t.b >>> 16) + (n >>> 16), o = (65535 & r) << 16 | 65535 & n, n = (65535 & e.a) + (65535 & t.a) + (r >>> 16), r = (e.a >>> 16) + (t.a >>> 16) + (n >>> 16), new i((65535 & r) << 16 | 65535 & n, o)
             }
             function z(e, t, n, r) {
                 var o, a, c;
                 return o = (65535 & e.b) + (65535 & t.b) + (65535 & n.b) + (65535 & r.b), a = (e.b >>> 16) + (t.b >>> 16) + (n.b >>> 16) + (r.b >>> 16) + (o >>> 16), c = (65535 & a) << 16 | 65535 & o, o = (65535 & e.a) + (65535 & t.a) + (65535 & n.a) + (65535 & r.a) + (a >>> 16), a = (e.a >>> 16) + (t.a >>> 16) + (n.a >>> 16) + (r.a >>> 16) + (o >>> 16), new i((65535 & a) << 16 | 65535 & o, c)
             }
             function U(e, t, n, r, o) {
                 var a, c, s;
                 return a = (65535 & e.b) + (65535 & t.b) + (65535 & n.b) + (65535 & r.b) + (65535 & o.b), c = (e.b >>> 16) + (t.b >>> 16) + (n.b >>> 16) + (r.b >>> 16) + (o.b >>> 16) + (a >>> 16), s = (65535 & c) << 16 | 65535 & a, a = (65535 & e.a) + (65535 & t.a) + (65535 & n.a) + (65535 & r.a) + (65535 & o.a) + (c >>> 16), c = (e.a >>> 16) + (t.a >>> 16) + (n.a >>> 16) + (r.a >>> 16) + (o.a >>> 16) + (a >>> 16), new i((65535 & c) << 16 | 65535 & a, s)
             }
             function B(e) {
                 var t, n = 0,
                     r = 0;
                 for (t = 0; t < arguments.length; t += 1) n ^= arguments[t].b, r ^= arguments[t].a;
                 return new i(r, n)
             }
             function F(e) {
                 var t, n = [];
                 if ("SHA-1" === e) n = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
                 else if (0 === e.lastIndexOf("SHA-", 0)) switch (n = [3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428], t = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], e) {
                     case "SHA-224":
                         break;
                     case "SHA-256":
                         n = t;
                         break;
                     case "SHA-384":
                         n = [new i(3418070365, n[0]), new i(1654270250, n[1]), new i(2438529370, n[2]), new i(355462360, n[3]), new i(1731405415, n[4]), new i(41048885895, n[5]), new i(3675008525, n[6]), new i(1203062813, n[7])];
                         break;
                     case "SHA-512":
                         n = [new i(t[0], 4089235720), new i(t[1], 2227873595), new i(t[2], 4271175723), new i(t[3], 1595750129), new i(t[4], 2917565137), new i(t[5], 725511199), new i(t[6], 4215389547), new i(t[7], 327033209)];
                         break;
                     default:
                         throw Error("Unknown SHA variant")
                 } else {
                     if (0 !== e.lastIndexOf("SHA3-", 0) && 0 !== e.lastIndexOf("SHAKE", 0)) throw Error("No SHA variants supported");
                     for (e = 0; 5 > e; e += 1) n[e] = [new i(0, 0), new i(0, 0), new i(0, 0), new i(0, 0), new i(0, 0)]
                 }
                 return n
             }
             function q(e, t) {
                 var n, r, o, a, i, c, s, u = [];
                 for (n = t[0], r = t[1], o = t[2], a = t[3], i = t[4], s = 0; 80 > s; s += 1) u[s] = 16 > s ? e[s] : y(u[s - 3] ^ u[s - 8] ^ u[s - 14] ^ u[s - 16], 1), c = 20 > s ? D(y(n, 5), r & o ^ ~r & a, i, 1518500249, u[s]) : 40 > s ? D(y(n, 5), r ^ o ^ a, i, 1859775393, u[s]) : 60 > s ? D(y(n, 5), C(r, o, a), i, 2400959708, u[s]) : D(y(n, 5), r ^ o ^ a, i, 3395469782, u[s]), i = a, a = o, o = y(r, 30), r = n, n = c;
                 return t[0] = R(n, t[0]), t[1] = R(r, t[1]), t[2] = R(o, t[2]), t[3] = R(a, t[3]), t[4] = R(i, t[4]), t
             }
             function H(e, t, n, r) {
                 var o;
                 for (o = 15 + (t + 65 >>> 9 << 4); e.length <= o;) e.push(0);
                 for (e[t >>> 5] |= 128 << 24 - t % 32, t += n, e[o] = 4294967295 & t, e[o - 1] = t / 4294967296 | 0, t = e.length, o = 0; o < t; o += 16) r = q(e.slice(o, o + 16), r);
                 return r
             }
             function V(e, t, n) {
                 var r, o, a, c, s, u, l, f, p, d, h, m, v, y, b, g, w, E, B, F, q, H, V, G = [];
                 if ("SHA-224" === n || "SHA-256" === n) d = 64, m = 1, H = Number, v = R, y = M, b = D, g = A, w = I, E = S, B = j, q = C, F = _, V = W;
                 else {
                     if ("SHA-384" !== n && "SHA-512" !== n) throw Error("Unexpected error in SHA-2 implementation");
                     d = 80, m = 2, H = i, v = L, y = z, b = U, g = x, w = N, E = k, B = P, q = T, F = O, V = K
                 }
                 for (n = t[0], r = t[1], o = t[2], a = t[3], c = t[4], s = t[5], u = t[6], l = t[7], h = 0; h < d; h += 1) 16 > h ? (p = h * m, f = e.length <= p ? 0 : e[p], p = e.length <= p + 1 ? 0 : e[p + 1], G[h] = new H(f, p)) : G[h] = y(w(G[h - 2]), G[h - 7], g(G[h - 15]), G[h - 16]), f = b(l, B(c), F(c, s, u), V[h], G[h]), p = v(E(n), q(n, r, o)), l = u, u = s, s = c, c = v(a, f), a = o, o = r, r = n, n = v(f, p);
                 return t[0] = v(n, t[0]), t[1] = v(r, t[1]), t[2] = v(o, t[2]), t[3] = v(a, t[3]), t[4] = v(c, t[4]), t[5] = v(s, t[5]), t[6] = v(u, t[6]), t[7] = v(l, t[7]), t
             }
             function G(e, t) {
                 var n, r, o, a, c = [],
                     s = [];
                 if (null !== e)
                     for (r = 0; r < e.length; r += 2) t[(r >>> 1) % 5][(r >>> 1) / 5 | 0] = B(t[(r >>> 1) % 5][(r >>> 1) / 5 | 0], new i((255 & e[r + 1]) << 24 | (65280 & e[r + 1]) << 8 | (16711680 & e[r + 1]) >>> 8 | e[r + 1] >>> 24, (255 & e[r]) << 24 | (65280 & e[r]) << 8 | (16711680 & e[r]) >>> 8 | e[r] >>> 24));
                 for (n = 0; 24 > n; n += 1) {
                     for (a = F("SHA3-"), r = 0; 5 > r; r += 1) c[r] = B(t[r][0], t[r][1], t[r][2], t[r][3], t[r][4]);
                     for (r = 0; 5 > r; r += 1) s[r] = B(c[(r + 4) % 5], b(c[(r + 1) % 5], 1));
                     for (r = 0; 5 > r; r += 1)
                         for (o = 0; 5 > o; o += 1) t[r][o] = B(t[r][o], s[r]);
                     for (r = 0; 5 > r; r += 1)
                         for (o = 0; 5 > o; o += 1) a[o][(2 * r + 3 * o) % 5] = b(t[r][o], Q[r][o]);
                     for (r = 0; 5 > r; r += 1)
                         for (o = 0; 5 > o; o += 1) t[r][o] = B(a[r][o], new i(~a[(r + 1) % 5][o].a & a[(r + 2) % 5][o].a, ~a[(r + 1) % 5][o].b & a[(r + 2) % 5][o].b));
                     t[0][0] = B(t[0][0], Y[n])
                 }
                 return t
             }
             function run(e,n){
                 // e = password,
                 // n 为时间戳,如1515735045595
                 //client_id,现在默认为 c3cef7c66a1843f8b3a9e6a1e3160e20
                 client_id = 'c3cef7c66a1843f8b3a9e6a1e3160e20';
                 r = new a("SHA-1", "TEXT");
                 r.setHMACKey("d1b964811afb40118a12068ff74a12f4", "TEXT");
                 r.update(e);
                 r.update(client_id);
                 r.update("com.zhihu.web");
                 r.update(String(n));
                 return r.getHMAC("HEX")
             }
     """)
     signature = js1.call('run', 'password', timestamp)
     data = {
         'client_id': client_id, 'grant_type': 'password',
         'timestamp': str(timestamp), 'source': 'com.zhihu.web',
         'signature': signature, 'username': username,
         'password': password, 'captcha': captcha,
         'lang': 'en', 'ref_source': 'homepage', 'utm_source': ''
     }
     return data
Ejemplo n.º 49
0
def get_g_tk(p_skey):
    # 加载js
    execjs_execjs = execjs.compile(get_others_js())
    return execjs_execjs.call('getToken', p_skey)
Ejemplo n.º 50
0
def get_ptqrtoken(qrsign):
    # 加载js
    execjs_execjs = execjs.compile(get_others_js())
    return execjs_execjs.call('hash33', qrsign)
Ejemplo n.º 51
0
def get_callback_data(call_fun):
    # 加载js
    execjs_execjs = execjs.compile(get_others_js())
    return execjs_execjs.call('getData', call_fun)
Ejemplo n.º 52
0
 def __init__(self):
     path = react.source.path_for('JSXTransformer.js')
     with open(path, 'rU') as f:
         self.context = execjs.compile(f.read())
Ejemplo n.º 53
0
def des_encode(encode_data, key1, key2, key3):
    des_js = execjs.compile(js_content)
    encoded_string = des_js.call("strEnc", encode_data, key1, key2, key3)
    return encoded_string
Ejemplo n.º 54
0
 def get_password(self):
     # 密码的 加密方法
     js_ = """
     navigator = {}; window=this;
     function i(t, e, n) {
             null != t && ("number" == typeof t ? this.fromNumber(t, e, n) : null == e && "string" != typeof t ? this.fromString(t, 256) : this.fromString(t, e))
         }
         function r() {
             return new i(null)
         }
         "Microsoft Internet Explorer" == navigator.appName ? (i.prototype.am = function(t, e, n, o, i, r) {
             for (var a = 32767 & e, s = e >> 15; --r >= 0; ) {
                 var c = 32767 & this[t]
                   , u = this[t++] >> 15
                   , l = s * c + u * a;
                 i = ((c = a * c + ((32767 & l) << 15) + n[o] + (1073741823 & i)) >>> 30) + (l >>> 15) + s * u + (i >>> 30),
                 n[o++] = 1073741823 & c
             }
             return i
         }
         ,
         o = 30) : "Netscape" != navigator.appName ? (i.prototype.am = function(t, e, n, o, i, r) {
             for (; --r >= 0; ) {
                 var a = e * this[t++] + n[o] + i;
                 i = Math.floor(a / 67108864),
                 n[o++] = 67108863 & a
             }
             return i
         }
         ,
         o = 26) : (i.prototype.am = function(t, e, n, o, i, r) {
             for (var a = 16383 & e, s = e >> 14; --r >= 0; ) {
                 var c = 16383 & this[t]
                   , u = this[t++] >> 14
                   , l = s * c + u * a;
                 i = ((c = a * c + ((16383 & l) << 14) + n[o] + i) >> 28) + (l >> 14) + s * u,
                 n[o++] = 268435455 & c
             }
             return i
         }
         ,
         o = 28),
         i.prototype.DB = o,
         i.prototype.DM = (1 << o) - 1,
         i.prototype.DV = 1 << o;
         i.prototype.FV = Math.pow(2, 52),
         i.prototype.F1 = 52 - o,
         i.prototype.F2 = 2 * o - 52;
         var a, s, c = "0123456789abcdefghijklmnopqrstuvwxyz", u = new Array;
         for (a = "0".charCodeAt(0),
         s = 0; s <= 9; ++s)
             u[a++] = s;
         for (a = "a".charCodeAt(0),
         s = 10; s < 36; ++s)
             u[a++] = s;
         for (a = "A".charCodeAt(0),
         s = 10; s < 36; ++s)
             u[a++] = s;
         function l(t) {
             return c.charAt(t)
         }
         function f(t, e) {
             var n = u[t.charCodeAt(e)];
             return null == n ? -1 : n
         }
         function p(t) {
             var e = r();
             return e.fromInt(t),
             e
         }
         function d(t) {
             var e, n = 1;
             return 0 != (e = t >>> 16) && (t = e,
             n += 16),
             0 != (e = t >> 8) && (t = e,
             n += 8),
             0 != (e = t >> 4) && (t = e,
             n += 4),
             0 != (e = t >> 2) && (t = e,
             n += 2),
             0 != (e = t >> 1) && (t = e,
             n += 1),
             n
         }
         function h(t) {
             this.m = t
         }
         function g(t) {
             this.m = t,
             this.mp = t.invDigit(),
             this.mpl = 32767 & this.mp,
             this.mph = this.mp >> 15,
             this.um = (1 << t.DB - 15) - 1,
             this.mt2 = 2 * t.t
         }
         function y() {
             this.i = 0,
             this.j = 0,
             this.S = new Array
         }
         h.prototype.convert = function(t) {
             return t.s < 0 || t.compareTo(this.m) >= 0 ? t.mod(this.m) : t
         }
         ,
         h.prototype.revert = function(t) {
             return t
         }
         ,
         h.prototype.reduce = function(t) {
             t.divRemTo(this.m, null, t)
         }
         ,
         h.prototype.mulTo = function(t, e, n) {
             t.multiplyTo(e, n),
             this.reduce(n)
         }
         ,
         h.prototype.sqrTo = function(t, e) {
             t.squareTo(e),
             this.reduce(e)
         }
         ,
         g.prototype.convert = function(t) {
             var e = r();
             return t.abs().dlShiftTo(this.m.t, e),
             e.divRemTo(this.m, null, e),
             t.s < 0 && e.compareTo(i.ZERO) > 0 && this.m.subTo(e, e),
             e
         }
         ,
         g.prototype.revert = function(t) {
             var e = r();
             return t.copyTo(e),
             this.reduce(e),
             e
         }
         ,
         g.prototype.reduce = function(t) {
             for (; t.t <= this.mt2; )
                 t[t.t++] = 0;
             for (var e = 0; e < this.m.t; ++e) {
                 var n = 32767 & t[e]
                   , o = n * this.mpl + ((n * this.mph + (t[e] >> 15) * this.mpl & this.um) << 15) & t.DM;
                 for (t[n = e + this.m.t] += this.m.am(0, o, t, e, 0, this.m.t); t[n] >= t.DV; )
                     t[n] -= t.DV,
                     t[++n]++
             }
             t.clamp(),
             t.drShiftTo(this.m.t, t),
             t.compareTo(this.m) >= 0 && t.subTo(this.m, t)
         }
         ,
         g.prototype.mulTo = function(t, e, n) {
             t.multiplyTo(e, n),
             this.reduce(n)
         }
         ,
         g.prototype.sqrTo = function(t, e) {
             t.squareTo(e),
             this.reduce(e)
         }
         ,
         i.prototype.copyTo = function(t) {
             for (var e = this.t - 1; e >= 0; --e)
                 t[e] = this[e];
             t.t = this.t,
             t.s = this.s
         }
         ,
         i.prototype.fromInt = function(t) {
             this.t = 1,
             this.s = t < 0 ? -1 : 0,
             t > 0 ? this[0] = t : t < -1 ? this[0] = t + this.DV : this.t = 0
         }
         ,
         i.prototype.fromString = function(t, e) {
             var n;
             if (16 == e)
                 n = 4;
             else if (8 == e)
                 n = 3;
             else if (256 == e)
                 n = 8;
             else if (2 == e)
                 n = 1;
             else if (32 == e)
                 n = 5;
             else {
                 if (4 != e)
                     return void this.fromRadix(t, e);
                 n = 2
             }
             this.t = 0,
             this.s = 0;
             for (var o = t.length, r = !1, a = 0; --o >= 0; ) {
                 var s = 8 == n ? 255 & t[o] : f(t, o);
                 s < 0 ? "-" == t.charAt(o) && (r = !0) : (r = !1,
                 0 == a ? this[this.t++] = s : a + n > this.DB ? (this[this.t - 1] |= (s & (1 << this.DB - a) - 1) << a,
                 this[this.t++] = s >> this.DB - a) : this[this.t - 1] |= s << a,
                 (a += n) >= this.DB && (a -= this.DB))
             }
             8 == n && 0 != (128 & t[0]) && (this.s = -1,
             a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)),
             this.clamp(),
             r && i.ZERO.subTo(this, this)
         }
         ,
         i.prototype.clamp = function() {
             for (var t = this.s & this.DM; this.t > 0 && this[this.t - 1] == t; )
                 --this.t
         }
         ,
         i.prototype.dlShiftTo = function(t, e) {
             var n;
             for (n = this.t - 1; n >= 0; --n)
                 e[n + t] = this[n];
             for (n = t - 1; n >= 0; --n)
                 e[n] = 0;
             e.t = this.t + t,
             e.s = this.s
         }
         ,
         i.prototype.drShiftTo = function(t, e) {
             for (var n = t; n < this.t; ++n)
                 e[n - t] = this[n];
             e.t = Math.max(this.t - t, 0),
             e.s = this.s
         }
         ,
         i.prototype.lShiftTo = function(t, e) {
             var n, o = t % this.DB, i = this.DB - o, r = (1 << i) - 1, a = Math.floor(t / this.DB), s = this.s << o & this.DM;
             for (n = this.t - 1; n >= 0; --n)
                 e[n + a + 1] = this[n] >> i | s,
                 s = (this[n] & r) << o;
             for (n = a - 1; n >= 0; --n)
                 e[n] = 0;
             e[a] = s,
             e.t = this.t + a + 1,
             e.s = this.s,
             e.clamp()
         }
         ,
         i.prototype.rShiftTo = function(t, e) {
             e.s = this.s;
             var n = Math.floor(t / this.DB);
             if (n >= this.t)
                 e.t = 0;
             else {
                 var o = t % this.DB
                   , i = this.DB - o
                   , r = (1 << o) - 1;
                 e[0] = this[n] >> o;
                 for (var a = n + 1; a < this.t; ++a)
                     e[a - n - 1] |= (this[a] & r) << i,
                     e[a - n] = this[a] >> o;
                 o > 0 && (e[this.t - n - 1] |= (this.s & r) << i),
                 e.t = this.t - n,
                 e.clamp()
             }
         }
         ,
         i.prototype.subTo = function(t, e) {
             for (var n = 0, o = 0, i = Math.min(t.t, this.t); n < i; )
                 o += this[n] - t[n],
                 e[n++] = o & this.DM,
                 o >>= this.DB;
             if (t.t < this.t) {
                 for (o -= t.s; n < this.t; )
                     o += this[n],
                     e[n++] = o & this.DM,
                     o >>= this.DB;
                 o += this.s
             } else {
                 for (o += this.s; n < t.t; )
                     o -= t[n],
                     e[n++] = o & this.DM,
                     o >>= this.DB;
                 o -= t.s
             }
             e.s = o < 0 ? -1 : 0,
             o < -1 ? e[n++] = this.DV + o : o > 0 && (e[n++] = o),
             e.t = n,
             e.clamp()
         }
         ,
         i.prototype.multiplyTo = function(t, e) {
             var n = this.abs()
               , o = t.abs()
               , r = n.t;
             for (e.t = r + o.t; --r >= 0; )
                 e[r] = 0;
             for (r = 0; r < o.t; ++r)
                 e[r + n.t] = n.am(0, o[r], e, r, 0, n.t);
             e.s = 0,
             e.clamp(),
             this.s != t.s && i.ZERO.subTo(e, e)
         }
         ,
         i.prototype.squareTo = function(t) {
             for (var e = this.abs(), n = t.t = 2 * e.t; --n >= 0; )
                 t[n] = 0;
             for (n = 0; n < e.t - 1; ++n) {
                 var o = e.am(n, e[n], t, 2 * n, 0, 1);
                 (t[n + e.t] += e.am(n + 1, 2 * e[n], t, 2 * n + 1, o, e.t - n - 1)) >= e.DV && (t[n + e.t] -= e.DV,
                 t[n + e.t + 1] = 1)
             }
             t.t > 0 && (t[t.t - 1] += e.am(n, e[n], t, 2 * n, 0, 1)),
             t.s = 0,
             t.clamp()
         }
         ,
         i.prototype.divRemTo = function(t, e, n) {
             var o = t.abs();
             if (!(o.t <= 0)) {
                 var a = this.abs();
                 if (a.t < o.t)
                     return null != e && e.fromInt(0),
                     void (null != n && this.copyTo(n));
                 null == n && (n = r());
                 var s = r()
                   , c = this.s
                   , u = t.s
                   , l = this.DB - d(o[o.t - 1]);
                 l > 0 ? (o.lShiftTo(l, s),
                 a.lShiftTo(l, n)) : (o.copyTo(s),
                 a.copyTo(n));
                 var f = s.t
                   , p = s[f - 1];
                 if (0 != p) {
                     var h = p * (1 << this.F1) + (f > 1 ? s[f - 2] >> this.F2 : 0)
                       , g = this.FV / h
                       , y = (1 << this.F1) / h
                       , m = 1 << this.F2
                       , v = n.t
                       , M = v - f
                       , w = null == e ? r() : e;
                     for (s.dlShiftTo(M, w),
                     n.compareTo(w) >= 0 && (n[n.t++] = 1,
                     n.subTo(w, n)),
                     i.ONE.dlShiftTo(f, w),
                     w.subTo(s, s); s.t < f; )
                         s[s.t++] = 0;
                     for (; --M >= 0; ) {
                         var b = n[--v] == p ? this.DM : Math.floor(n[v] * g + (n[v - 1] + m) * y);
                         if ((n[v] += s.am(0, b, n, M, 0, f)) < b)
                             for (s.dlShiftTo(M, w),
                             n.subTo(w, n); n[v] < --b; )
                                 n.subTo(w, n)
                     }
                     null != e && (n.drShiftTo(f, e),
                     c != u && i.ZERO.subTo(e, e)),
                     n.t = f,
                     n.clamp(),
                     l > 0 && n.rShiftTo(l, n),
                     c < 0 && i.ZERO.subTo(n, n)
                 }
             }
         }
         ,
         i.prototype.invDigit = function() {
             if (this.t < 1)
                 return 0;
             var t = this[0];
             if (0 == (1 & t))
                 return 0;
             var e = 3 & t;
             return (e = (e = (e = (e = e * (2 - (15 & t) * e) & 15) * (2 - (255 & t) * e) & 255) * (2 - ((65535 & t) * e & 65535)) & 65535) * (2 - t * e % this.DV) % this.DV) > 0 ? this.DV - e : -e
         }
         ,
         i.prototype.isEven = function() {
             return 0 == (this.t > 0 ? 1 & this[0] : this.s)
         }
         ,
         i.prototype.exp = function(t, e) {
             if (t > 4294967295 || t < 1)
                 return i.ONE;
             var n = r()
               , o = r()
               , a = e.convert(this)
               , s = d(t) - 1;
             for (a.copyTo(n); --s >= 0; )
                 if (e.sqrTo(n, o),
                 (t & 1 << s) > 0)
                     e.mulTo(o, a, n);
                 else {
                     var c = n;
                     n = o,
                     o = c
                 }
             return e.revert(n)
         }
         ,
         i.prototype.toString = function(t) {
             if (this.s < 0)
                 return "-" + this.negate().toString(t);
             var e;
             if (16 == t)
                 e = 4;
             else if (8 == t)
                 e = 3;
             else if (2 == t)
                 e = 1;
             else if (32 == t)
                 e = 5;
             else {
                 if (4 != t)
                     return this.toRadix(t);
                 e = 2
             }
             var n, o = (1 << e) - 1, i = !1, r = "", a = this.t, s = this.DB - a * this.DB % e;
             if (a-- > 0)
                 for (s < this.DB && (n = this[a] >> s) > 0 && (i = !0,
                 r = l(n)); a >= 0; )
                     s < e ? (n = (this[a] & (1 << s) - 1) << e - s,
                     n |= this[--a] >> (s += this.DB - e)) : (n = this[a] >> (s -= e) & o,
                     s <= 0 && (s += this.DB,
                     --a)),
                     n > 0 && (i = !0),
                     i && (r += l(n));
             return i ? r : "0"
         }
         ,
         i.prototype.negate = function() {
             var t = r();
             return i.ZERO.subTo(this, t),
             t
         }
         ,
         i.prototype.abs = function() {
             return this.s < 0 ? this.negate() : this
         }
         ,
         i.prototype.compareTo = function(t) {
             var e = this.s - t.s;
             if (0 != e)
                 return e;
             var n = this.t;
             if (0 != (e = n - t.t))
                 return this.s < 0 ? -e : e;
             for (; --n >= 0; )
                 if (0 != (e = this[n] - t[n]))
                     return e;
             return 0
         }
         ,
         i.prototype.bitLength = function() {
             return this.t <= 0 ? 0 : this.DB * (this.t - 1) + d(this[this.t - 1] ^ this.s & this.DM)
         }
         ,
         i.prototype.mod = function(t) {
             var e = r();
             return this.abs().divRemTo(t, null, e),
             this.s < 0 && e.compareTo(i.ZERO) > 0 && t.subTo(e, e),
             e
         }
         ,
         i.prototype.modPowInt = function(t, e) {
             var n;
             return n = t < 256 || e.isEven() ? new h(e) : new g(e),
             this.exp(t, n)
         }
         ,
         i.ZERO = p(0),
         i.ONE = p(1),
         y.prototype.init = function(t) {
             var e, n, o;
             for (e = 0; e < 256; ++e)
                 this.S[e] = e;
             for (n = 0,
             e = 0; e < 256; ++e)
                 n = n + this.S[e] + t[e % t.length] & 255,
                 o = this.S[e],
                 this.S[e] = this.S[n],
                 this.S[n] = o;
             this.i = 0,
             this.j = 0
         }
         ,
         y.prototype.next = function() {
             var t;
             return this.i = this.i + 1 & 255,
             this.j = this.j + this.S[this.i] & 255,
             t = this.S[this.i],
             this.S[this.i] = this.S[this.j],
             this.S[this.j] = t,
             this.S[t + this.S[this.i] & 255]
         }
         ;
         var m, v, M, w = 256;
         function b() {
             !function(t) {
                 v[M++] ^= 255 & t,
                 v[M++] ^= t >> 8 & 255,
                 v[M++] ^= t >> 16 & 255,
                 v[M++] ^= t >> 24 & 255,
                 M >= w && (M -= w)
             }((new Date).getTime())
         }
         if (null == v) {
             var N;
             if (v = new Array,
             M = 0,
             window.crypto && window.crypto.getRandomValues) {
                 var C = new Uint8Array(32);
                 for (window.crypto.getRandomValues(C),
                 N = 0; N < 32; ++N)
                     v[M++] = C[N]
             }
             if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto && window.crypto.random) {
                 var T = window.crypto.random(32);
                 for (N = 0; N < T.length; ++N)
                     v[M++] = 255 & T.charCodeAt(N)
             }
             for (; M < w; )
                 N = Math.floor(65536 * Math.random()),
                 v[M++] = N >>> 8,
                 v[M++] = 255 & N;
             M = 0,
             b()
         }
         function I() {
             if (null == m) {
                 for (b(),
                 (m = new y).init(v),
                 M = 0; M < v.length; ++M)
                     v[M] = 0;
                 M = 0
             }
             return m.next()
         }
         function j() {}
         function D() {
             this.n = null,
             this.e = 0,
             this.d = null,
             this.p = null,
             this.q = null,
             this.dmp1 = null,
             this.dmq1 = null,
             this.coeff = null
         }
         j.prototype.nextBytes = function(t) {
             var e;
             for (e = 0; e < t.length; ++e)
                 t[e] = I()
         }
         ,
         D.prototype.doPublic = function(t) {
             return t.modPowInt(this.e, this.n)
         }
         ,
         D.prototype.setPublic = function(t, e) {
             null != t && null != e && t.length > 0 && e.length > 0 ? (this.n = function(t, e) {
                 return new i(t,e)
             }(t, 16),
             this.e = parseInt(e, 16)) : alert("Invalid RSA public key")
         }
         ,
         D.prototype.encrypt = function(t) {
             var e = function(t, e) {
                 if (e < t.length + 11)
                     return alert("Message too long for RSA"),
                     null;
                 for (var n = new Array, o = t.length - 1; o >= 0 && e > 0; ) {
                     var r = t.charCodeAt(o--);
                     r < 128 ? n[--e] = r : r > 127 && r < 2048 ? (n[--e] = 63 & r | 128,
                     n[--e] = r >> 6 | 192) : (n[--e] = 63 & r | 128,
                     n[--e] = r >> 6 & 63 | 128,
                     n[--e] = r >> 12 | 224)
                 }
                 n[--e] = 0;
                 for (var a = new j, s = new Array; e > 2; ) {
                     for (s[0] = 0; 0 == s[0]; )
                         a.nextBytes(s);
                     n[--e] = s[0]
                 }
                 return n[--e] = 2,
                 n[--e] = 0,
                 new i(n)
             }(t, this.n.bitLength() + 7 >> 3);
             if (null == e)
                 return null;
             var n = this.doPublic(e);
             if (null == n)
                 return null;
             var o = n.toString(16);
             return 0 == (1 & o.length) ? o : "0" + o
         }
     rsaPassword = function(t) { 	
         var e = new D; 	
         return e.setPublic("d3bcef1f00424f3261c89323fa8cdfa12bbac400d9fe8bb627e8d27a44bd5d59dce559135d678a8143beb5b8d7056c4e1f89c4e1f152470625b7b41944a97f02da6f605a49a93ec6eb9cbaf2e7ac2b26a354ce69eb265953d2c29e395d6d8c1cdb688978551aa0f7521f290035fad381178da0bea8f9e6adce39020f513133fb", "10001"), 	
         e.encrypt(t) 
     }  
     function getPwd(pwd) { 
         return rsaPassword(pwd);
      }
     
     """
     pwd = execjs.compile(js_).call("getPwd", self.pwd)
     return pwd
Ejemplo n.º 55
0
def get_pt():
    # 加载js
    execjs_execjs = execjs.compile(get_pt_js())
    return execjs_execjs.call('getPt', None)
Ejemplo n.º 56
0
import requests
import re
import execjs
import urllib3
urllib3.disable_warnings()
url = 'https://blog.csdn.net/qq_32786139/article/details/103666149'
headers = dict()
headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)' \
                        ' Chrome/73.0.3683.75 Safari/537.36'
session = requests.session()
response = session.get(url, headers=headers, verify=False)
html_js = response.content.decode()
arg1 = re.search(r'var arg1=\'(.*)\';', html_js).group(1)
with open('sojson_CSDN.js', 'r') as f:
    SDK = f.read()
ctx = execjs.compile(SDK)
acw_sc__v2 = ctx.call('SDK', arg1)
print(acw_sc__v2)
cookies = {'acw_sc__v2': acw_sc__v2}
response = session.get(url, headers=headers, verify=False, cookies=cookies)
html = response.content.decode()
print(html)
print(acw_sc__v2)
print(acw_sc__v2)
print(acw_sc__v2)
print(acw_sc__v2)
Ejemplo n.º 57
0
import execjs

# 解释器
print(execjs.get().name)

# 直接执行js
e = execjs.eval('a = new Array(1,2,3)')
print(e)

# 编译之后执行
jstext = """
function hello(str){return str;}
"""

ctx = execjs.compile(jstext)
a = ctx.call('hello', 'hello world')
print(a)
        def fun():
            proxies = self.make_proxies()
            self.guid = self.make_guid()
            print('进程:{} Start get Number'.format(os.getpid()))
            self.number = self.get_number()
            print('进程:{} Start get vjkl5'.format(os.getpid()))
            self.vjkl5 = self.get_vjkl5()
            if not self.vjkl5:
                return
            nonlocal retry
            if retry <= 0:
                return None
            else:
                retry -= 1
            headers = {
                'Host': 'wenshu.court.gov.cn',
                'Connection': 'keep-alive',
                'Upgrade-Insecure-Requests': '1',
                'Accept': 'text/javascript, application/javascript, */*',
                'X-Requested-With': 'XMLHttpRequest',
                'Referer': url1,
                'Accept-Encoding': 'gzip,deflate',
                'Accept-Language': 'zh-CN,zh;q=0.9'
            }

            try:
                print('进程:{} Start get Response'.format(os.getpid()))
                headers.setdefault('User-Agent', UserAgent().random)
                response = self.s.get(url,
                                      headers=headers,
                                      proxies=proxies,
                                      timeout=TIMEOUT)
                # response = self.s.get(url, headers=headers, timeout=TIMEOUT)
                if isinstance(response,
                              Response) and response.status_code == 200:
                    response.encoding = 'utf-8'
                    try:
                        dynamicurl = re.search('dynamicurl="(.*?)"',
                                               response.text).group(1)
                        wzwsquestion = re.search('wzwsquestion="(.*?)"',
                                                 response.text).group(1)
                        wzwsfactor = re.search('wzwsfactor="(.*?)"',
                                               response.text).group(1)
                        wzwsmethod = re.search('wzwsmethod="(.*?)"',
                                               response.text).group(1)
                        wzwsparams = re.search('wzwsparams="(.*?)"',
                                               response.text).group(1)
                    except AttributeError:
                        return None

                    js_dynamicurl = '''
                    var dynamicurl="{}";var wzwsquestion="{}";var wzwsfactor="{}";var wzwsmethod="{}";var wzwsparams
                    ="{}";'''.format(dynamicurl, wzwsquestion, wzwsfactor,
                                     wzwsmethod, wzwsparams)
                    js_code = js_dynamicurl + js_wzwschallenge
                    ctx = execjs.compile(js_code)
                    wzwschallenge = ctx.call("wzwschallenge")
                    print('进程:{} wzwschallenge>>> {}'.format(
                        os.getpid(), wzwschallenge))
                    next_url = 'http://wenshu.court.gov.cn' + dynamicurl + '?' + 'wzwschallenge=' + wzwschallenge

                    resp = self.s.get(next_url,
                                      proxies=proxies,
                                      headers=headers,
                                      timeout=TIMEOUT)
                    # resp = self.s.get(next_url, headers=headers)
                    if isinstance(resp, Response) and resp.status_code == 200:
                        resp.encoding = 'utf-8'
                        if 'window.location.href=' in response.text:
                            raise ValueError("请求详情页出错!")
                        else:
                            return resp
                    else:
                        raise ValueError("请求详情页出错!")
                else:
                    raise ValueError("请求详情页出错!")
            except (ReadTimeout, ProxyError, ConnectionError,
                    ContentDecodingError, ChunkedEncodingError, ValueError,
                    KeyError):
                if retry == 3 or retry == 1:
                    time.sleep(60)
                return fun()
Ejemplo n.º 59
0
import PyV8

# ctxt = PyV8.JSContext()
# ctxt.enter()
# func = ctxt.eval("""
#     (function add(x, y){
#         return x + y;
#         })
# """)
#
# print(func(1, 2))

import execjs

js = execjs.compile("""
    function add(x, y){
        return x + y;
        }
    """)

print(js.call("add", 1, 2))
Ejemplo n.º 60
0
 def get_cookie(self, value, js):
     return execjs.compile(js).call('_a', value)