{"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.__init__","parameters":"(\n self,\n width=800,\n height=400,\n renderer=constants.CANVAS_RENDERER,\n page_title=constants.PAGE_TITLE,\n extra_html_text_label=None,\n is_animation=True,\n )","argument_list":"","return_statement":"","docstring":":param width:\n \u753b\u5e03\u5bbd\u5ea6\uff0c\u9ed8\u8ba4\u4e3a 800\uff08px\uff09\n :param height:\n \u753b\u5e03\u9ad8\u5ea6\uff0c\u9ed8\u8ba4\u4e3a 400\uff08px\uff09\n :param renderer:\n \u6307\u5b9a\u4f7f\u7528\u6e32\u67d3\u65b9\u5f0f\uff0c\u6709 'svg' \u548c 'canvas' \u53ef\u9009\uff0c\u9ed8\u8ba4\u4e3a 'canvas'\u3002\n 3D \u56fe\u4ec5\u80fd\u4f7f\u7528 'canvas'\u3002\n :param page_title:\n \u6307\u5b9a\u751f\u6210\u7684 html \u6587\u4ef6\u4e2d
\u6807\u7b7e)\u3002\u7c7b\u578b\u4e3a list\uff0clist[0] \u4e3a\u6587\u672c\u5185\u5bb9\uff0c\n list[1] \u4e3a\u5b57\u4f53\u98ce\u683c\u6837\u5f0f\uff08\u9009\u586b\uff09\u3002\u5982 [\"this is a p label\", \"color:red\"]\n :param is_animation:\n \u662f\u5426\u5f00\u542f\u52a8\u753b\uff0c\u9ed8\u8ba4\u4e3a True\u3002V0.5.9+","docstring_summary":"","docstring_tokens":[],"function":"def __init__(\n self,\n width=800,\n height=400,\n renderer=constants.CANVAS_RENDERER,\n page_title=constants.PAGE_TITLE,\n extra_html_text_label=None,\n is_animation=True,\n ):\n \"\"\"\n\n :param width:\n \u753b\u5e03\u5bbd\u5ea6\uff0c\u9ed8\u8ba4\u4e3a 800\uff08px\uff09\n :param height:\n \u753b\u5e03\u9ad8\u5ea6\uff0c\u9ed8\u8ba4\u4e3a 400\uff08px\uff09\n :param renderer:\n \u6307\u5b9a\u4f7f\u7528\u6e32\u67d3\u65b9\u5f0f\uff0c\u6709 'svg' \u548c 'canvas' \u53ef\u9009\uff0c\u9ed8\u8ba4\u4e3a 'canvas'\u3002\n 3D \u56fe\u4ec5\u80fd\u4f7f\u7528 'canvas'\u3002\n :param page_title:\n \u6307\u5b9a\u751f\u6210\u7684 html \u6587\u4ef6\u4e2d
\u6807\u7b7e)\u3002\u7c7b\u578b\u4e3a list\uff0clist[0] \u4e3a\u6587\u672c\u5185\u5bb9\uff0c\n list[1] \u4e3a\u5b57\u4f53\u98ce\u683c\u6837\u5f0f\uff08\u9009\u586b\uff09\u3002\u5982 [\"this is a p label\", \"color:red\"]\n :param is_animation:\n \u662f\u5426\u5f00\u542f\u52a8\u753b\uff0c\u9ed8\u8ba4\u4e3a True\u3002V0.5.9+\n \"\"\"\n self._option = {}\n self._js_dependencies = set()\n self._chart_id = uuid.uuid4().hex\n self.width, self.height = width, height\n self.renderer = renderer\n self._page_title = page_title\n self._js_dependencies = {\"echarts\"}\n self.event_handlers = {}\n self.theme = None\n self.use_theme(CURRENT_CONFIG.theme)\n self.extra_html_text_label = extra_html_text_label\n self.is_animation = is_animation","function_tokens":["def","__init__","(","self",",","width","=","800",",","height","=","400",",","renderer","=","constants",".","CANVAS_RENDERER",",","page_title","=","constants",".","PAGE_TITLE",",","extra_html_text_label","=","None",",","is_animation","=","True",",",")",":","self",".","_option","=","{","}","self",".","_js_dependencies","=","set","(",")","self",".","_chart_id","=","uuid",".","uuid4","(",")",".","hex","self",".","width",",","self",".","height","=","width",",","height","self",".","renderer","=","renderer","self",".","_page_title","=","page_title","self",".","_js_dependencies","=","{","\"echarts\"","}","self",".","event_handlers","=","{","}","self",".","theme","=","None","self",".","use_theme","(","CURRENT_CONFIG",".","theme",")","self",".","extra_html_text_label","=","extra_html_text_label","self",".","is_animation","=","is_animation"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L24-L61"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.print_echarts_options","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_summary":"\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_tokens":["\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879"],"function":"def print_echarts_options(self):\n \"\"\"\n \u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879\n \"\"\"\n snippet = TRANSLATOR.translate(self.options)\n print(snippet.as_snippet())","function_tokens":["def","print_echarts_options","(","self",")",":","snippet","=","TRANSLATOR",".","translate","(","self",".","options",")","print","(","snippet",".","as_snippet","(",")",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L99-L104"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.get_echarts_options","parameters":"(self)","argument_list":"","return_statement":"return snippet.as_snippet()","docstring":"\u8fd4\u56de\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_summary":"\u8fd4\u56de\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_tokens":["\u8fd4\u56de\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879"],"function":"def get_echarts_options(self):\n \"\"\"\n \u8fd4\u56de\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879\n \"\"\"\n snippet = TRANSLATOR.translate(self.options)\n return snippet.as_snippet()","function_tokens":["def","get_echarts_options","(","self",")",":","snippet","=","TRANSLATOR",".","translate","(","self",".","options",")","return","snippet",".","as_snippet","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L106-L111"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.show_config","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_summary":"\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879","docstring_tokens":["\u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879"],"function":"def show_config(self):\n \"\"\"\n \u6253\u5370\u8f93\u51fa\u56fe\u5f62\u6240\u6709\u914d\u7f6e\u9879\n \"\"\"\n deprecated_tpl = \"The {} is deprecated, please use {} instead!\"\n warnings.warn(\n deprecated_tpl.format(\"show_config\", \"print_echarts_options\"),\n DeprecationWarning,\n )\n self.print_echarts_options()","function_tokens":["def","show_config","(","self",")",":","deprecated_tpl","=","\"The {} is deprecated, please use {} instead!\"","warnings",".","warn","(","deprecated_tpl",".","format","(","\"show_config\"",",","\"print_echarts_options\"",")",",","DeprecationWarning",",",")","self",".","print_echarts_options","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L113-L122"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.render_embed","parameters":"(self)","argument_list":"","return_statement":"return Markup(html)","docstring":"\u6e32\u67d3\u56fe\u8868\u7684\u6240\u6709\u914d\u7f6e\u9879\uff0c\u4e3a web pages \u670d\u52a1\uff0c\u4e0d\u8fc7\u9700\u5148\u63d0\u4f9b\u6240\u9700\u8981\u7684js \u4f9d\u8d56\u6587\u4ef6","docstring_summary":"\u6e32\u67d3\u56fe\u8868\u7684\u6240\u6709\u914d\u7f6e\u9879\uff0c\u4e3a web pages \u670d\u52a1\uff0c\u4e0d\u8fc7\u9700\u5148\u63d0\u4f9b\u6240\u9700\u8981\u7684js \u4f9d\u8d56\u6587\u4ef6","docstring_tokens":["\u6e32\u67d3\u56fe\u8868\u7684\u6240\u6709\u914d\u7f6e\u9879\uff0c\u4e3a","web","pages","\u670d\u52a1\uff0c\u4e0d\u8fc7\u9700\u5148\u63d0\u4f9b\u6240\u9700\u8981\u7684js","\u4f9d\u8d56\u6587\u4ef6"],"function":"def render_embed(self):\n \"\"\"\n \u6e32\u67d3\u56fe\u8868\u7684\u6240\u6709\u914d\u7f6e\u9879\uff0c\u4e3a web pages \u670d\u52a1\uff0c\u4e0d\u8fc7\u9700\u5148\u63d0\u4f9b\u6240\u9700\u8981\u7684js \u4f9d\u8d56\u6587\u4ef6\n \"\"\"\n env = engine.create_default_environment(constants.DEFAULT_HTML)\n html = env.render_container_and_echarts_code(self)\n return Markup(html)","function_tokens":["def","render_embed","(","self",")",":","env","=","engine",".","create_default_environment","(","constants",".","DEFAULT_HTML",")","html","=","env",".","render_container_and_echarts_code","(","self",")","return","Markup","(","html",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L124-L130"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.get_js_dependencies","parameters":"(self)","argument_list":"","return_statement":"return CURRENT_CONFIG.produce_html_script_list(self._js_dependencies)","docstring":"\u58f0\u660e\u6240\u6709\u7684 js \u6587\u4ef6\u8def\u5f84","docstring_summary":"\u58f0\u660e\u6240\u6709\u7684 js \u6587\u4ef6\u8def\u5f84","docstring_tokens":["\u58f0\u660e\u6240\u6709\u7684","js","\u6587\u4ef6\u8def\u5f84"],"function":"def get_js_dependencies(self):\n \"\"\"\n \u58f0\u660e\u6240\u6709\u7684 js \u6587\u4ef6\u8def\u5f84\n \"\"\"\n return CURRENT_CONFIG.produce_html_script_list(self._js_dependencies)","function_tokens":["def","get_js_dependencies","(","self",")",":","return","CURRENT_CONFIG",".","produce_html_script_list","(","self",".","_js_dependencies",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L132-L136"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base.cast","parameters":"(seq)","argument_list":"","return_statement":"return k_lst, v_lst","docstring":"\u8f6c\u6362\u6570\u636e\u5e8f\u5217\uff0c\u5c06\u5e26\u5b57\u5178\u548c\u5143\u7ec4\u7c7b\u578b\u7684\u5e8f\u5217\u8f6c\u6362\u4e3a k_lst,v_lst \u4e24\u4e2a\u5217\u8868\n\n \u5143\u7ec4\u5217\u8868\n [(A1, B1), (A2, B2), ...] -->\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n \u5b57\u5178\u5217\u8868\n [{A1: B1}, {A2: B2}, ...] -->\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n \u5b57\u5178\n {A1: B1, A2: B2, ...} -- >\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n\n :param seq:\n \u5f85\u8f6c\u6362\u7684\u5e8f\u5217\n :return:","docstring_summary":"\u8f6c\u6362\u6570\u636e\u5e8f\u5217\uff0c\u5c06\u5e26\u5b57\u5178\u548c\u5143\u7ec4\u7c7b\u578b\u7684\u5e8f\u5217\u8f6c\u6362\u4e3a k_lst,v_lst \u4e24\u4e2a\u5217\u8868","docstring_tokens":["\u8f6c\u6362\u6570\u636e\u5e8f\u5217\uff0c\u5c06\u5e26\u5b57\u5178\u548c\u5143\u7ec4\u7c7b\u578b\u7684\u5e8f\u5217\u8f6c\u6362\u4e3a","k_lst","v_lst","\u4e24\u4e2a\u5217\u8868"],"function":"def cast(seq):\n \"\"\"\n \u8f6c\u6362\u6570\u636e\u5e8f\u5217\uff0c\u5c06\u5e26\u5b57\u5178\u548c\u5143\u7ec4\u7c7b\u578b\u7684\u5e8f\u5217\u8f6c\u6362\u4e3a k_lst,v_lst \u4e24\u4e2a\u5217\u8868\n\n \u5143\u7ec4\u5217\u8868\n [(A1, B1), (A2, B2), ...] -->\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n \u5b57\u5178\u5217\u8868\n [{A1: B1}, {A2: B2}, ...] -->\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n \u5b57\u5178\n {A1: B1, A2: B2, ...} -- >\n k_lst[ A[i1, i2...] ], v_lst[ B[i1, i2...] ]\n\n :param seq:\n \u5f85\u8f6c\u6362\u7684\u5e8f\u5217\n :return:\n \"\"\"\n k_lst, v_lst = [], []\n if isinstance(seq, list):\n for s in seq:\n if isinstance(s, tuple):\n _attr, _value = s\n k_lst.append(_attr)\n v_lst.append(_value)\n elif isinstance(s, dict):\n for k, v in s.items():\n k_lst.append(k)\n v_lst.append(v)\n elif isinstance(seq, dict):\n for key in sorted(list(seq.keys())):\n k_lst.append(key)\n v_lst.append(seq[key])\n return k_lst, v_lst","function_tokens":["def","cast","(","seq",")",":","k_lst",",","v_lst","=","[","]",",","[","]","if","isinstance","(","seq",",","list",")",":","for","s","in","seq",":","if","isinstance","(","s",",","tuple",")",":","_attr",",","_value","=","s","k_lst",".","append","(","_attr",")","v_lst",".","append","(","_value",")","elif","isinstance","(","s",",","dict",")",":","for","k",",","v","in","s",".","items","(",")",":","k_lst",".","append","(","k",")","v_lst",".","append","(","v",")","elif","isinstance","(","seq",",","dict",")",":","for","key","in","sorted","(","list","(","seq",".","keys","(",")",")",")",":","k_lst",".","append","(","key",")","v_lst",".","append","(","seq","[","key","]",")","return","k_lst",",","v_lst"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L157-L190"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base._repr_html_","parameters":"(self)","argument_list":"","return_statement":"","docstring":"\u6e32\u67d3\u914d\u7f6e\u9879\u5e76\u5c06\u56fe\u5f62\u663e\u793a\u5728 notebook \u4e2d\n\n chart\/page => charts\n chart.js_dependencies => require_config => config_items, libraries\n :return A unicode string.","docstring_summary":"\u6e32\u67d3\u914d\u7f6e\u9879\u5e76\u5c06\u56fe\u5f62\u663e\u793a\u5728 notebook \u4e2d","docstring_tokens":["\u6e32\u67d3\u914d\u7f6e\u9879\u5e76\u5c06\u56fe\u5f62\u663e\u793a\u5728","notebook","\u4e2d"],"function":"def _repr_html_(self):\n \"\"\"\n \u6e32\u67d3\u914d\u7f6e\u9879\u5e76\u5c06\u56fe\u5f62\u663e\u793a\u5728 notebook \u4e2d\n\n chart\/page => charts\n chart.js_dependencies => require_config => config_items, libraries\n :return A unicode string.\n \"\"\"\n if CURRENT_CONFIG.jupyter_presentation == constants.DEFAULT_HTML:\n require_config = CURRENT_CONFIG.produce_require_configuration(\n self.js_dependencies\n )\n config_items = require_config[\"config_items\"]\n libraries = require_config[\"libraries\"]\n env = engine.create_default_environment(constants.DEFAULT_HTML)\n return env.render_chart_to_notebook(\n charts=(self,), config_items=config_items, libraries=libraries\n )\n\n elif CURRENT_CONFIG.jupyter_presentation == constants.NTERACT:\n env = engine.create_default_environment(constants.DEFAULT_HTML)\n return env.render_chart_to_notebook(\n chart=self, template_name=\"nteract.html\"\n )\n\n else:\n return None","function_tokens":["def","_repr_html_","(","self",")",":","if","CURRENT_CONFIG",".","jupyter_presentation","==","constants",".","DEFAULT_HTML",":","require_config","=","CURRENT_CONFIG",".","produce_require_configuration","(","self",".","js_dependencies",")","config_items","=","require_config","[","\"config_items\"","]","libraries","=","require_config","[","\"libraries\"","]","env","=","engine",".","create_default_environment","(","constants",".","DEFAULT_HTML",")","return","env",".","render_chart_to_notebook","(","charts","=","(","self",",",")",",","config_items","=","config_items",",","libraries","=","libraries",")","elif","CURRENT_CONFIG",".","jupyter_presentation","==","constants",".","NTERACT",":","env","=","engine",".","create_default_environment","(","constants",".","DEFAULT_HTML",")","return","env",".","render_chart_to_notebook","(","chart","=","self",",","template_name","=","\"nteract.html\"",")","else",":","return","None"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L202-L228"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/base.py","language":"python","identifier":"Base._render_as_image","parameters":"(self, file_type)","argument_list":"","return_statement":"return content","docstring":"This is an internal function to serve _repr_jpeg_,\n _repr_png_ and _repr_svg_.\n\n :param file_type: the parameter is mostly image file types.","docstring_summary":"This is an internal function to serve _repr_jpeg_,\n _repr_png_ and _repr_svg_.","docstring_tokens":["This","is","an","internal","function","to","serve","_repr_jpeg_","_repr_png_","and","_repr_svg_","."],"function":"def _render_as_image(self, file_type):\n \"\"\"\n This is an internal function to serve _repr_jpeg_,\n _repr_png_ and _repr_svg_.\n\n :param file_type: the parameter is mostly image file types.\n \"\"\"\n if CURRENT_CONFIG.jupyter_presentation != file_type:\n return None\n\n if self.renderer == constants.SVG_RENDERER:\n if file_type != constants.SVG:\n raise exceptions.InvalidConfiguration(\n \"svg renderer produces only svg image.\"\n )\n\n elif file_type not in [constants.JPEG, constants.PNG]:\n # CANVAS_RENDERER here\n raise exceptions.InvalidConfiguration(\n \"svg output requires svg renderer.\"\n )\n\n env = engine.create_default_environment(file_type)\n tmp_file_handle, tmp_file_path = mkstemp(suffix=\".\" + file_type)\n content = env.render_chart_to_file(\n chart=self, path=tmp_file_path, verbose=False\n )\n os.close(tmp_file_handle)\n return content","function_tokens":["def","_render_as_image","(","self",",","file_type",")",":","if","CURRENT_CONFIG",".","jupyter_presentation","!=","file_type",":","return","None","if","self",".","renderer","==","constants",".","SVG_RENDERER",":","if","file_type","!=","constants",".","SVG",":","raise","exceptions",".","InvalidConfiguration","(","\"svg renderer produces only svg image.\"",")","elif","file_type","not","in","[","constants",".","JPEG",",","constants",".","PNG","]",":","# CANVAS_RENDERER here","raise","exceptions",".","InvalidConfiguration","(","\"svg output requires svg renderer.\"",")","env","=","engine",".","create_default_environment","(","file_type",")","tmp_file_handle",",","tmp_file_path","=","mkstemp","(","suffix","=","\".\"","+","file_type",")","content","=","env",".","render_chart_to_file","(","chart","=","self",",","path","=","tmp_file_path",",","verbose","=","False",")","os",".","close","(","tmp_file_handle",")","return","content"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/base.py#L243-L271"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/request\/__init__.py","language":"python","identifier":"Request.copy","parameters":"(self)","argument_list":"","return_statement":"return self.replace()","docstring":"Return a copy of this Request","docstring_summary":"Return a copy of this Request","docstring_tokens":["Return","a","copy","of","this","Request"],"function":"def copy(self):\n \"\"\"Return a copy of this Request\"\"\"\n return self.replace()","function_tokens":["def","copy","(","self",")",":","return","self",".","replace","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/request\/__init__.py#L110-L112"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/request\/__init__.py","language":"python","identifier":"Request.replace","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"return cls(*args, **kwargs)","docstring":"Create a new Request with the same attributes except for those\n given new values.","docstring_summary":"Create a new Request with the same attributes except for those\n given new values.","docstring_tokens":["Create","a","new","Request","with","the","same","attributes","except","for","those","given","new","values","."],"function":"def replace(self, *args, **kwargs):\n \"\"\"Create a new Request with the same attributes except for those\n given new values.\n \"\"\"\n for x in ['url', 'method', 'headers', 'body', 'cookies', 'meta',\n 'encoding', 'priority', 'dont_filter', 'callback', 'errback']:\n kwargs.setdefault(x, getattr(self, x))\n cls = kwargs.pop('cls', self.__class__)\n return cls(*args, **kwargs)","function_tokens":["def","replace","(","self",",","*","args",",","*","*","kwargs",")",":","for","x","in","[","'url'",",","'method'",",","'headers'",",","'body'",",","'cookies'",",","'meta'",",","'encoding'",",","'priority'",",","'dont_filter'",",","'callback'",",","'errback'","]",":","kwargs",".","setdefault","(","x",",","getattr","(","self",",","x",")",")","cls","=","kwargs",".","pop","(","'cls'",",","self",".","__class__",")","return","cls","(","*","args",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/request\/__init__.py#L114-L122"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.copy","parameters":"(self)","argument_list":"","return_statement":"return self.replace()","docstring":"Return a copy of this Response","docstring_summary":"Return a copy of this Response","docstring_tokens":["Return","a","copy","of","this","Response"],"function":"def copy(self):\n \"\"\"Return a copy of this Response\"\"\"\n return self.replace()","function_tokens":["def","copy","(","self",")",":","return","self",".","replace","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L71-L73"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.replace","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"return cls(*args, **kwargs)","docstring":"Create a new Response with the same attributes except for those\n given new values.","docstring_summary":"Create a new Response with the same attributes except for those\n given new values.","docstring_tokens":["Create","a","new","Response","with","the","same","attributes","except","for","those","given","new","values","."],"function":"def replace(self, *args, **kwargs):\n \"\"\"Create a new Response with the same attributes except for those\n given new values.\n \"\"\"\n for x in ['url', 'status', 'headers', 'body', 'request', 'flags']:\n kwargs.setdefault(x, getattr(self, x))\n cls = kwargs.pop('cls', self.__class__)\n return cls(*args, **kwargs)","function_tokens":["def","replace","(","self",",","*","args",",","*","*","kwargs",")",":","for","x","in","[","'url'",",","'status'",",","'headers'",",","'body'",",","'request'",",","'flags'","]",":","kwargs",".","setdefault","(","x",",","getattr","(","self",",","x",")",")","cls","=","kwargs",".","pop","(","'cls'",",","self",".","__class__",")","return","cls","(","*","args",",","*","*","kwargs",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L75-L82"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.urljoin","parameters":"(self, url)","argument_list":"","return_statement":"return urljoin(self.url, url)","docstring":"Join this Response's url with a possible relative url to form an\n absolute interpretation of the latter.","docstring_summary":"Join this Response's url with a possible relative url to form an\n absolute interpretation of the latter.","docstring_tokens":["Join","this","Response","s","url","with","a","possible","relative","url","to","form","an","absolute","interpretation","of","the","latter","."],"function":"def urljoin(self, url):\n \"\"\"Join this Response's url with a possible relative url to form an\n absolute interpretation of the latter.\"\"\"\n return urljoin(self.url, url)","function_tokens":["def","urljoin","(","self",",","url",")",":","return","urljoin","(","self",".","url",",","url",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L84-L87"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.text","parameters":"(self)","argument_list":"","return_statement":"","docstring":"For subclasses of TextResponse, this will return the body\n as text (unicode object in Python 2 and str in Python 3)","docstring_summary":"For subclasses of TextResponse, this will return the body\n as text (unicode object in Python 2 and str in Python 3)","docstring_tokens":["For","subclasses","of","TextResponse","this","will","return","the","body","as","text","(","unicode","object","in","Python","2","and","str","in","Python","3",")"],"function":"def text(self):\n \"\"\"For subclasses of TextResponse, this will return the body\n as text (unicode object in Python 2 and str in Python 3)\n \"\"\"\n raise AttributeError(\"Response content isn't text\")","function_tokens":["def","text","(","self",")",":","raise","AttributeError","(","\"Response content isn't text\"",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L90-L94"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.css","parameters":"(self, *a, **kw)","argument_list":"","return_statement":"","docstring":"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).","docstring_summary":"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).","docstring_tokens":["Shortcut","method","implemented","only","by","responses","whose","content","is","text","(","subclasses","of","TextResponse",")","."],"function":"def css(self, *a, **kw):\n \"\"\"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).\n \"\"\"\n raise NotSupported(\"Response content isn't text\")","function_tokens":["def","css","(","self",",","*","a",",","*","*","kw",")",":","raise","NotSupported","(","\"Response content isn't text\"",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L96-L100"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.xpath","parameters":"(self, *a, **kw)","argument_list":"","return_statement":"","docstring":"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).","docstring_summary":"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).","docstring_tokens":["Shortcut","method","implemented","only","by","responses","whose","content","is","text","(","subclasses","of","TextResponse",")","."],"function":"def xpath(self, *a, **kw):\n \"\"\"Shortcut method implemented only by responses whose content\n is text (subclasses of TextResponse).\n \"\"\"\n raise NotSupported(\"Response content isn't text\")","function_tokens":["def","xpath","(","self",",","*","a",",","*","*","kw",")",":","raise","NotSupported","(","\"Response content isn't text\"",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L102-L106"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"source_code\/response\/__init__.py","language":"python","identifier":"Response.follow","parameters":"(self, url, callback=None, method='GET', headers=None, body=None,\n cookies=None, meta=None, encoding='utf-8', priority=0,\n dont_filter=False, errback=None)","argument_list":"","return_statement":"return Request(url, callback,\n method=method,\n headers=headers,\n body=body,\n cookies=cookies,\n meta=meta,\n encoding=encoding,\n priority=priority,\n dont_filter=dont_filter,\n errback=errback)","docstring":"Return a :class:`~.Request` instance to follow a link ``url``.\n It accepts the same arguments as ``Request.__init__`` method,\n but ``url`` can be a relative URL or a ``scrapy.link.Link`` object,\n not only an absolute URL.\n \n :class:`~.TextResponse` provides a :meth:`~.TextResponse.follow` \n method which supports selectors in addition to absolute\/relative URLs\n and Link objects.","docstring_summary":"Return a :class:`~.Request` instance to follow a link ``url``.\n It accepts the same arguments as ``Request.__init__`` method,\n but ``url`` can be a relative URL or a ``scrapy.link.Link`` object,\n not only an absolute URL.\n \n :class:`~.TextResponse` provides a :meth:`~.TextResponse.follow` \n method which supports selectors in addition to absolute\/relative URLs\n and Link objects.","docstring_tokens":["Return","a",":","class",":","~",".","Request","instance","to","follow","a","link","url",".","It","accepts","the","same","arguments","as","Request",".","__init__","method","but","url","can","be","a","relative","URL","or","a","scrapy",".","link",".","Link","object","not","only","an","absolute","URL",".",":","class",":","~",".","TextResponse","provides","a",":","meth",":","~",".","TextResponse",".","follow","method","which","supports","selectors","in","addition","to","absolute","\/","relative","URLs","and","Link","objects","."],"function":"def follow(self, url, callback=None, method='GET', headers=None, body=None,\n cookies=None, meta=None, encoding='utf-8', priority=0,\n dont_filter=False, errback=None):\n # type: (...) -> Request\n \"\"\"\n Return a :class:`~.Request` instance to follow a link ``url``.\n It accepts the same arguments as ``Request.__init__`` method,\n but ``url`` can be a relative URL or a ``scrapy.link.Link`` object,\n not only an absolute URL.\n \n :class:`~.TextResponse` provides a :meth:`~.TextResponse.follow` \n method which supports selectors in addition to absolute\/relative URLs\n and Link objects.\n \"\"\"\n if isinstance(url, Link):\n url = url.url\n url = self.urljoin(url)\n return Request(url, callback,\n method=method,\n headers=headers,\n body=body,\n cookies=cookies,\n meta=meta,\n encoding=encoding,\n priority=priority,\n dont_filter=dont_filter,\n errback=errback)","function_tokens":["def","follow","(","self",",","url",",","callback","=","None",",","method","=","'GET'",",","headers","=","None",",","body","=","None",",","cookies","=","None",",","meta","=","None",",","encoding","=","'utf-8'",",","priority","=","0",",","dont_filter","=","False",",","errback","=","None",")",":","# type: (...) -> Request","if","isinstance","(","url",",","Link",")",":","url","=","url",".","url","url","=","self",".","urljoin","(","url",")","return","Request","(","url",",","callback",",","method","=","method",",","headers","=","headers",",","body","=","body",",","cookies","=","cookies",",","meta","=","meta",",","encoding","=","encoding",",","priority","=","priority",",","dont_filter","=","dont_filter",",","errback","=","errback",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/source_code\/response\/__init__.py#L108-L134"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.__init__","parameters":"(self, phone)","argument_list":"","return_statement":"","docstring":":param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f","docstring_summary":":param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f","docstring_tokens":[":","param","phone",":","adb","\u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f"],"function":"def __init__(self, phone):\n \"\"\"\n :param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f\n \"\"\"\n # \u4e00\u4e0b\u5199\u6cd5\u4e0d\u7406\u89e3\u53c2\u8003https:\/\/stackoverflow.com\/questions\/11179008\/python-inheritance-typeerror-object-init-takes-no-parameters\n PhoneControl.__init__(self,phone=phone)","function_tokens":["def","__init__","(","self",",","phone",")",":","# \u4e00\u4e0b\u5199\u6cd5\u4e0d\u7406\u89e3\u53c2\u8003https:\/\/stackoverflow.com\/questions\/11179008\/python-inheritance-typeerror-object-init-takes-no-parameters","PhoneControl",".","__init__","(","self",",","phone","=","phone",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L10-L15"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.click_by_words","parameters":"(self,words,tap=True)","argument_list":"","return_statement":"return pos","docstring":"\u70b9\u51fb\u6307\u5b9awords\u6240\u5728\u7684\u533a\u57df\n :param words:\u76ee\u6807\u6587\u5b57\n :return:\u5b9e\u9645\u70b9\u51fb\u7684\u4f4d\u7f6e","docstring_summary":"\u70b9\u51fb\u6307\u5b9awords\u6240\u5728\u7684\u533a\u57df\n :param words:\u76ee\u6807\u6587\u5b57\n :return:\u5b9e\u9645\u70b9\u51fb\u7684\u4f4d\u7f6e","docstring_tokens":["\u70b9\u51fb\u6307\u5b9awords\u6240\u5728\u7684\u533a\u57df",":","param","words",":","\u76ee\u6807\u6587\u5b57",":","return",":","\u5b9e\u9645\u70b9\u51fb\u7684\u4f4d\u7f6e"],"function":"def click_by_words(self,words,tap=True):\n \"\"\"\n \u70b9\u51fb\u6307\u5b9awords\u6240\u5728\u7684\u533a\u57df\n :param words:\u76ee\u6807\u6587\u5b57\n :return:\u5b9e\u9645\u70b9\u51fb\u7684\u4f4d\u7f6e\n \"\"\"\n # \u622a\u56fe\n pic_name = self.get_screen_cap()\n # COR\u8bc6\u522bui_words\n ui_words = VC.ocr(pic_name ,location=True)\n # \u6839\u636ewords\u627e\u6700\u76f8\u4f3c\n prob, loc_words = VC.find_position(ui_words, words)\n # \u6267\u884c\u70b9\u51fb\n loc = loc_words['location']\n pos = [loc['left'],loc['top'],loc['left']+loc['width'],loc['top']+loc['height']]\n if tap is True:\n self.input_tap(pos)\n return pos","function_tokens":["def","click_by_words","(","self",",","words",",","tap","=","True",")",":","# \u622a\u56fe","pic_name","=","self",".","get_screen_cap","(",")","# COR\u8bc6\u522bui_words","ui_words","=","VC",".","ocr","(","pic_name",",","location","=","True",")","# \u6839\u636ewords\u627e\u6700\u76f8\u4f3c","prob",",","loc_words","=","VC",".","find_position","(","ui_words",",","words",")","# \u6267\u884c\u70b9\u51fb","loc","=","loc_words","[","'location'","]","pos","=","[","loc","[","'left'","]",",","loc","[","'top'","]",",","loc","[","'left'","]","+","loc","[","'width'","]",",","loc","[","'top'","]","+","loc","[","'height'","]","]","if","tap","is","True",":","self",".","input_tap","(","pos",")","return","pos"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L17-L34"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.click_by_loc","parameters":"(self,pos)","argument_list":"","return_statement":"return acture_pos","docstring":"\u6839\u636e\u533a\u57df\u4f4d\u7f6e\u70b9\u51fb\u5c4f\u5e55 \u540c\u65f6\u652f\u6301 \u70b9\u4f4d\u7f6e\n :param pos:\u533a\u57df\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u5750\u6807\n :return:","docstring_summary":"\u6839\u636e\u533a\u57df\u4f4d\u7f6e\u70b9\u51fb\u5c4f\u5e55 \u540c\u65f6\u652f\u6301 \u70b9\u4f4d\u7f6e\n :param pos:\u533a\u57df\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u5750\u6807\n :return:","docstring_tokens":["\u6839\u636e\u533a\u57df\u4f4d\u7f6e\u70b9\u51fb\u5c4f\u5e55","\u540c\u65f6\u652f\u6301","\u70b9\u4f4d\u7f6e",":","param","pos",":","\u533a\u57df\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u5750\u6807",":","return",":"],"function":"def click_by_loc(self,pos):\n \"\"\"\n \u6839\u636e\u533a\u57df\u4f4d\u7f6e\u70b9\u51fb\u5c4f\u5e55 \u540c\u65f6\u652f\u6301 \u70b9\u4f4d\u7f6e\n :param pos:\u533a\u57df\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u5750\u6807\n :return:\n \"\"\"\n acture_pos = self.input_tap(pos)\n return acture_pos","function_tokens":["def","click_by_loc","(","self",",","pos",")",":","acture_pos","=","self",".","input_tap","(","pos",")","return","acture_pos"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L36-L43"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.x_ray","parameters":"(self, keys, crop=None)","argument_list":"","return_statement":"return x_ray_data","docstring":"\u6839\u636e\u7ed9\u5b9a\u7684\u5173\u952e\u5b57\u8fd4\u56de\u5b83\u4eec\u7684\u4f4d\u7f6e\u5217\u8868 \u5e76\u4e14\u7ed9\u51fa\u76f8\u4f3c\u5ea6 \u5927\u4e8e0.9\u57fa\u672c\u53ef\u4fe1\n :param keys:('key1','key2',...)\n :param crop:\u805a\u7126\u88c1\u526a\u533a\u57df \u8be5tuple\u4e2d\u4fe1\u606f\u4e3a(left, upper, right, lower) \u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:{'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},...}","docstring_summary":"\u6839\u636e\u7ed9\u5b9a\u7684\u5173\u952e\u5b57\u8fd4\u56de\u5b83\u4eec\u7684\u4f4d\u7f6e\u5217\u8868 \u5e76\u4e14\u7ed9\u51fa\u76f8\u4f3c\u5ea6 \u5927\u4e8e0.9\u57fa\u672c\u53ef\u4fe1\n :param keys:('key1','key2',...)\n :param crop:\u805a\u7126\u88c1\u526a\u533a\u57df \u8be5tuple\u4e2d\u4fe1\u606f\u4e3a(left, upper, right, lower) \u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:{'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},...}","docstring_tokens":["\u6839\u636e\u7ed9\u5b9a\u7684\u5173\u952e\u5b57\u8fd4\u56de\u5b83\u4eec\u7684\u4f4d\u7f6e\u5217\u8868","\u5e76\u4e14\u7ed9\u51fa\u76f8\u4f3c\u5ea6","\u5927\u4e8e0",".","9\u57fa\u672c\u53ef\u4fe1",":","param","keys",":","(","key1","key2","...",")",":","param","crop",":","\u805a\u7126\u88c1\u526a\u533a\u57df","\u8be5tuple\u4e2d\u4fe1\u606f\u4e3a","(","left","upper","right","lower",")","\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9",":","return",":","{","key1",":","{","pos",":","[","x1","y1","x2","y2","]","prob",":","0",".","998","}","key1",":","{","pos",":","[","x1","y1","x2","y2","]","prob",":","0",".","998","}","...","}"],"function":"def x_ray(self, keys, crop=None):\n \"\"\"\n \u6839\u636e\u7ed9\u5b9a\u7684\u5173\u952e\u5b57\u8fd4\u56de\u5b83\u4eec\u7684\u4f4d\u7f6e\u5217\u8868 \u5e76\u4e14\u7ed9\u51fa\u76f8\u4f3c\u5ea6 \u5927\u4e8e0.9\u57fa\u672c\u53ef\u4fe1\n :param keys:('key1','key2',...)\n :param crop:\u805a\u7126\u88c1\u526a\u533a\u57df \u8be5tuple\u4e2d\u4fe1\u606f\u4e3a(left, upper, right, lower) \u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:{'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},'key1':{'pos':[x1,y1,x2,y2],'prob':0.998},...}\n \"\"\"\n x_ray_data = {}\n # \u622a\u56fe\n pic_name = self.get_screen_cap()\n # \u83b7\u53d6\u56fe\u7247\u7684ui_words\n ui_words = VC.ocr(pic_name ,location=True, crop=crop)\n for key in keys:\n x_ray_data[key] = {}\n # \u627e\u5230\u6700\u76f8\u4f3cwords\n prob, loc_words = VC.find_position(ui_words, key)\n loc = loc_words['location']\n # \u957f\u5bbd\u8f6c\u5316\u4e3a\u53f3\u4e0b\u89d2\u5750\u6807\n pos = [loc['left'],loc['top'],loc['left']+loc['width'],loc['top']+loc['height']]\n x_ray_data[key]['pos'] = pos\n x_ray_data[key]['prob'] = prob\n return x_ray_data","function_tokens":["def","x_ray","(","self",",","keys",",","crop","=","None",")",":","x_ray_data","=","{","}","# \u622a\u56fe","pic_name","=","self",".","get_screen_cap","(",")","# \u83b7\u53d6\u56fe\u7247\u7684ui_words","ui_words","=","VC",".","ocr","(","pic_name",",","location","=","True",",","crop","=","crop",")","for","key","in","keys",":","x_ray_data","[","key","]","=","{","}","# \u627e\u5230\u6700\u76f8\u4f3cwords","prob",",","loc_words","=","VC",".","find_position","(","ui_words",",","key",")","loc","=","loc_words","[","'location'","]","# \u957f\u5bbd\u8f6c\u5316\u4e3a\u53f3\u4e0b\u89d2\u5750\u6807","pos","=","[","loc","[","'left'","]",",","loc","[","'top'","]",",","loc","[","'left'","]","+","loc","[","'width'","]",",","loc","[","'top'","]","+","loc","[","'height'","]","]","x_ray_data","[","key","]","[","'pos'","]","=","pos","x_ray_data","[","key","]","[","'prob'","]","=","prob","return","x_ray_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L58-L79"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.ui_words2vocb","parameters":"(ui_words)","argument_list":"","return_statement":"return vocab","docstring":"\u6839\u636e\u622a\u5c4f\u6587\u5b57\u4fe1\u606f\u83b7\u5f97\u8bcd\u5178\u7528\u4e8e\u63a5\u4e0b\u6765\u521b\u5efaone_hot\u5411\u91cf\n :param ui_words:\u6765\u81eaocr\u7ed3\u679c\n :return:\u5b57\u5178 \u6682\u65f6\u4e3a\u672a\u6dfb\u52a0\u505c\u7528\u8bcd","docstring_summary":"\u6839\u636e\u622a\u5c4f\u6587\u5b57\u4fe1\u606f\u83b7\u5f97\u8bcd\u5178\u7528\u4e8e\u63a5\u4e0b\u6765\u521b\u5efaone_hot\u5411\u91cf\n :param ui_words:\u6765\u81eaocr\u7ed3\u679c\n :return:\u5b57\u5178 \u6682\u65f6\u4e3a\u672a\u6dfb\u52a0\u505c\u7528\u8bcd","docstring_tokens":["\u6839\u636e\u622a\u5c4f\u6587\u5b57\u4fe1\u606f\u83b7\u5f97\u8bcd\u5178\u7528\u4e8e\u63a5\u4e0b\u6765\u521b\u5efaone_hot\u5411\u91cf",":","param","ui_words",":","\u6765\u81eaocr\u7ed3\u679c",":","return",":","\u5b57\u5178","\u6682\u65f6\u4e3a\u672a\u6dfb\u52a0\u505c\u7528\u8bcd"],"function":"def ui_words2vocb(ui_words):\n \"\"\"\n \u6839\u636e\u622a\u5c4f\u6587\u5b57\u4fe1\u606f\u83b7\u5f97\u8bcd\u5178\u7528\u4e8e\u63a5\u4e0b\u6765\u521b\u5efaone_hot\u5411\u91cf\n :param ui_words:\u6765\u81eaocr\u7ed3\u679c\n :return:\u5b57\u5178 \u6682\u65f6\u4e3a\u672a\u6dfb\u52a0\u505c\u7528\u8bcd\n \"\"\"\n vocab = ''\n for words in ui_words:\n vocab+=words['words']\n vocab = set(vocab)\n return vocab","function_tokens":["def","ui_words2vocb","(","ui_words",")",":","vocab","=","''","for","words","in","ui_words",":","vocab","+=","words","[","'words'","]","vocab","=","set","(","vocab",")","return","vocab"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L82-L92"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.find_position","parameters":"(ui_words, dest_words)","argument_list":"","return_statement":"return cos_sim[max_index], ui_words[max_index]","docstring":"\u6839\u636ecor\u8bc6\u522b\u7684ui_words\uff0c\u627e\u5230\u4e0e\u6307\u5b9a\u76ee\u6807dest_words\u6700\u76f8\u4f3c\u7684\u4f4d\u7f6e\n :param ui_words:\n :param dest_words:\n :return:\u7b2c\u4e00\u4e2a\u8fd4\u56de\u503c\u4e3a\u76f8\u4f3c\u5ea6\uff0c\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\u4e3a\u5bf9\u5e94\u7684ocr\u4fe1\u606f\uff0c\u5305\u542b\u6587\u672c\u548c\u4f4d\u7f6e\u4fe1\u606f\n 0.998, {'location': {'width': 119, 'top': 1863, 'left': 345, 'height': 40}, 'words': '\u901a\u8baf\u5f55'}","docstring_summary":"\u6839\u636ecor\u8bc6\u522b\u7684ui_words\uff0c\u627e\u5230\u4e0e\u6307\u5b9a\u76ee\u6807dest_words\u6700\u76f8\u4f3c\u7684\u4f4d\u7f6e\n :param ui_words:\n :param dest_words:\n :return:\u7b2c\u4e00\u4e2a\u8fd4\u56de\u503c\u4e3a\u76f8\u4f3c\u5ea6\uff0c\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\u4e3a\u5bf9\u5e94\u7684ocr\u4fe1\u606f\uff0c\u5305\u542b\u6587\u672c\u548c\u4f4d\u7f6e\u4fe1\u606f\n 0.998, {'location': {'width': 119, 'top': 1863, 'left': 345, 'height': 40}, 'words': '\u901a\u8baf\u5f55'}","docstring_tokens":["\u6839\u636ecor\u8bc6\u522b\u7684ui_words\uff0c\u627e\u5230\u4e0e\u6307\u5b9a\u76ee\u6807dest_words\u6700\u76f8\u4f3c\u7684\u4f4d\u7f6e",":","param","ui_words",":",":","param","dest_words",":",":","return",":","\u7b2c\u4e00\u4e2a\u8fd4\u56de\u503c\u4e3a\u76f8\u4f3c\u5ea6\uff0c\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\u4e3a\u5bf9\u5e94\u7684ocr\u4fe1\u606f\uff0c\u5305\u542b\u6587\u672c\u548c\u4f4d\u7f6e\u4fe1\u606f","0",".","998","{","location",":","{","width",":","119","top",":","1863","left",":","345","height",":","40","}","words",":","\u901a\u8baf\u5f55","}"],"function":"def find_position(ui_words, dest_words):\n \"\"\"\n \u6839\u636ecor\u8bc6\u522b\u7684ui_words\uff0c\u627e\u5230\u4e0e\u6307\u5b9a\u76ee\u6807dest_words\u6700\u76f8\u4f3c\u7684\u4f4d\u7f6e\n :param ui_words:\n :param dest_words:\n :return:\u7b2c\u4e00\u4e2a\u8fd4\u56de\u503c\u4e3a\u76f8\u4f3c\u5ea6\uff0c\u7b2c\u4e8c\u4e2a\u8fd4\u56de\u503c\u4e3a\u5bf9\u5e94\u7684ocr\u4fe1\u606f\uff0c\u5305\u542b\u6587\u672c\u548c\u4f4d\u7f6e\u4fe1\u606f\n 0.998, {'location': {'width': 119, 'top': 1863, 'left': 345, 'height': 40}, 'words': '\u901a\u8baf\u5f55'}\n \"\"\"\n vocab = VC.ui_words2vocb(ui_words)\n dictionary = list(vocab)\n vec_len = len(dictionary)\n keys = range(vec_len)\n dictionary = dict(zip(dictionary, keys))\n # \u8ba1\u7b97\u5f53ui\u754c\u9762\u6bcf\u4e00\u884cwords\u7684one-hot\u5411\u91cf\n ui_words_vec = []\n for words in ui_words:\n words_vec = np.zeros(vec_len)\n for word in words['words']:\n words_vec[dictionary[word]]+=1\n ui_words_vec.append(words_vec)\n ui_words_vec = np.array(ui_words_vec)\n\n # \u6839\u636e\u8bcd\u5178\u8ba1\u7b97\u673a\u76ee\u6807words\u7684one-hot\u8bcd\u5411\u91cf\n dest_words_vec = np.zeros(vec_len)\n for word in dest_words:\n if word not in dictionary:continue\n dest_words_vec[dictionary[word]]+=1\n\n #\u8ba1\u7b97\u4f59\u5f26\u5939\u89d2\n cos_sim = []\n for vec in ui_words_vec:\n cs = VC.cos_sim(dest_words_vec,vec)\n cos_sim.append(cs)\n\n #\u5bfb\u627e\u6700\u53ef\u80fd\u70b9\u51fb\u4f4d\u7f6e\n max_index = cos_sim.index(max(cos_sim))\n return cos_sim[max_index], ui_words[max_index]","function_tokens":["def","find_position","(","ui_words",",","dest_words",")",":","vocab","=","VC",".","ui_words2vocb","(","ui_words",")","dictionary","=","list","(","vocab",")","vec_len","=","len","(","dictionary",")","keys","=","range","(","vec_len",")","dictionary","=","dict","(","zip","(","dictionary",",","keys",")",")","# \u8ba1\u7b97\u5f53ui\u754c\u9762\u6bcf\u4e00\u884cwords\u7684one-hot\u5411\u91cf","ui_words_vec","=","[","]","for","words","in","ui_words",":","words_vec","=","np",".","zeros","(","vec_len",")","for","word","in","words","[","'words'","]",":","words_vec","[","dictionary","[","word","]","]","+=","1","ui_words_vec",".","append","(","words_vec",")","ui_words_vec","=","np",".","array","(","ui_words_vec",")","# \u6839\u636e\u8bcd\u5178\u8ba1\u7b97\u673a\u76ee\u6807words\u7684one-hot\u8bcd\u5411\u91cf","dest_words_vec","=","np",".","zeros","(","vec_len",")","for","word","in","dest_words",":","if","word","not","in","dictionary",":","continue","dest_words_vec","[","dictionary","[","word","]","]","+=","1","#\u8ba1\u7b97\u4f59\u5f26\u5939\u89d2","cos_sim","=","[","]","for","vec","in","ui_words_vec",":","cs","=","VC",".","cos_sim","(","dest_words_vec",",","vec",")","cos_sim",".","append","(","cs",")","#\u5bfb\u627e\u6700\u53ef\u80fd\u70b9\u51fb\u4f4d\u7f6e","max_index","=","cos_sim",".","index","(","max","(","cos_sim",")",")","return","cos_sim","[","max_index","]",",","ui_words","[","max_index","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L95-L131"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/VC.py","language":"python","identifier":"VC.cos_sim","parameters":"(a,b)","argument_list":"","return_statement":"return cs","docstring":"\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u6027\uff0c\u7ed3\u679c\u8d8a\u63a5\u8fd11\u8d8a\u76f8\u4f3c\n :param a:\n :param b:\n :return:","docstring_summary":"\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u6027\uff0c\u7ed3\u679c\u8d8a\u63a5\u8fd11\u8d8a\u76f8\u4f3c\n :param a:\n :param b:\n :return:","docstring_tokens":["\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u6027\uff0c\u7ed3\u679c\u8d8a\u63a5\u8fd11\u8d8a\u76f8\u4f3c",":","param","a",":",":","param","b",":",":","return",":"],"function":"def cos_sim(a,b):\n \"\"\"\n \u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u6027\uff0c\u7ed3\u679c\u8d8a\u63a5\u8fd11\u8d8a\u76f8\u4f3c\n :param a:\n :param b:\n :return:\n \"\"\"\n cs = np.dot(a, b)\/(np.linalg.norm(a)*np.linalg.norm(b))\n return cs","function_tokens":["def","cos_sim","(","a",",","b",")",":","cs","=","np",".","dot","(","a",",","b",")","\/","(","np",".","linalg",".","norm","(","a",")","*","np",".","linalg",".","norm","(","b",")",")","return","cs"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/VC.py#L134-L142"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"connect_phone","parameters":"(func)","argument_list":"","return_statement":"return wrapper","docstring":"\u88c5\u9970\u5668\u8d1f\u8d23\u6bcf\u6b21\u547d\u4ee4\u524d\u8fde\u63a5\u624b\u673a\n :param func:\n :return:","docstring_summary":"\u88c5\u9970\u5668\u8d1f\u8d23\u6bcf\u6b21\u547d\u4ee4\u524d\u8fde\u63a5\u624b\u673a\n :param func:\n :return:","docstring_tokens":["\u88c5\u9970\u5668\u8d1f\u8d23\u6bcf\u6b21\u547d\u4ee4\u524d\u8fde\u63a5\u624b\u673a",":","param","func",":",":","return",":"],"function":"def connect_phone(func):\n \"\"\"\n \u88c5\u9970\u5668\u8d1f\u8d23\u6bcf\u6b21\u547d\u4ee4\u524d\u8fde\u63a5\u624b\u673a\n :param func:\n :return:\n \"\"\"\n def wrapper(*args, **kwargs):\n system('adb connect '+args[0].phone)\n return func(*args, **kwargs)\n return wrapper","function_tokens":["def","connect_phone","(","func",")",":","def","wrapper","(","*","args",",","*","*","kwargs",")",":","system","(","'adb connect '","+","args","[","0","]",".","phone",")","return","func","(","*","args",",","*","*","kwargs",")","return","wrapper"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L6-L15"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.__init__","parameters":"(self, phone)","argument_list":"","return_statement":"","docstring":":param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f","docstring_summary":":param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f","docstring_tokens":[":","param","phone",":","adb","\u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f"],"function":"def __init__(self, phone):\n \"\"\"\n :param phone:adb \u64cd\u4f5c\u624b\u673a\u6240\u9700\u8981\u7684\u7aef\u53e3\u4fe1\u606f\n \"\"\"\n self.phone = phone","function_tokens":["def","__init__","(","self",",","phone",")",":","self",".","phone","=","phone"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L19-L23"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.get_phone","parameters":"(self)","argument_list":"","return_statement":"return self.phone","docstring":"\u83b7\u53d6\u5b9e\u4f8b\u624b\u673a\u7aef\u53e3\u4fe1\u606f","docstring_summary":"\u83b7\u53d6\u5b9e\u4f8b\u624b\u673a\u7aef\u53e3\u4fe1\u606f","docstring_tokens":["\u83b7\u53d6\u5b9e\u4f8b\u624b\u673a\u7aef\u53e3\u4fe1\u606f"],"function":"def get_phone(self):\n \"\"\"\n \u83b7\u53d6\u5b9e\u4f8b\u624b\u673a\u7aef\u53e3\u4fe1\u606f\n \"\"\"\n return self.phone","function_tokens":["def","get_phone","(","self",")",":","return","self",".","phone"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L25-L29"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.get_screen_cap","parameters":"(self, file_name='screen_cap')","argument_list":"","return_statement":"return file_name+'.png'","docstring":"\u83b7\u53d6\u622a\u56fe","docstring_summary":"\u83b7\u53d6\u622a\u56fe","docstring_tokens":["\u83b7\u53d6\u622a\u56fe"],"function":"def get_screen_cap(self, file_name='screen_cap'):\n \"\"\"\n \u83b7\u53d6\u622a\u56fe\n \"\"\"\n system('adb -s '+str(self.phone)+' shell screencap -p \/sdcard\/'+file_name+'.png')\n system('adb -s '+str(self.phone)+' pull \/sdcard\/'+file_name+'.png'+' .\/'+file_name+'.png')\n return file_name+'.png'","function_tokens":["def","get_screen_cap","(","self",",","file_name","=","'screen_cap'",")",":","system","(","'adb -s '","+","str","(","self",".","phone",")","+","' shell screencap -p \/sdcard\/'","+","file_name","+","'.png'",")","system","(","'adb -s '","+","str","(","self",".","phone",")","+","' pull \/sdcard\/'","+","file_name","+","'.png'","+","' .\/'","+","file_name","+","'.png'",")","return","file_name","+","'.png'"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L32-L38"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_tap","parameters":"(self, pos)","argument_list":"","return_statement":"return _pos","docstring":"\u70b9\u51fb\u5c4f\u5e55\n pos\u4e3a\u4e00\u4e2a\u533a\u57df\u7684\u5de6\u4e0a\u4e0e\u53f3\u4e0b\u5750\u6807\n \u5982\u679c\u4e8b\u5148\u5df2\u7ecf\u968f\u673a\u5316\u4e86pos\u53ef\u4ee5\u53ea\u662f\u4e00\u4e2a\u70b9 \u968f\u673a\u70b9\u51fb\u4e00\u4e2a\u4f4d\u7f6e\u662f\u4e3a\u9632\u6b62\u88ab\u88ab\u8ba4\u4e3a\u662f\u673a\u5668\u4eba\n \u8fd4\u56de\u5b9e\u9645\u70b9\u51fb\u4f4d\u7f6e","docstring_summary":"\u70b9\u51fb\u5c4f\u5e55\n pos\u4e3a\u4e00\u4e2a\u533a\u57df\u7684\u5de6\u4e0a\u4e0e\u53f3\u4e0b\u5750\u6807\n \u5982\u679c\u4e8b\u5148\u5df2\u7ecf\u968f\u673a\u5316\u4e86pos\u53ef\u4ee5\u53ea\u662f\u4e00\u4e2a\u70b9 \u968f\u673a\u70b9\u51fb\u4e00\u4e2a\u4f4d\u7f6e\u662f\u4e3a\u9632\u6b62\u88ab\u88ab\u8ba4\u4e3a\u662f\u673a\u5668\u4eba\n \u8fd4\u56de\u5b9e\u9645\u70b9\u51fb\u4f4d\u7f6e","docstring_tokens":["\u70b9\u51fb\u5c4f\u5e55","pos\u4e3a\u4e00\u4e2a\u533a\u57df\u7684\u5de6\u4e0a\u4e0e\u53f3\u4e0b\u5750\u6807","\u5982\u679c\u4e8b\u5148\u5df2\u7ecf\u968f\u673a\u5316\u4e86pos\u53ef\u4ee5\u53ea\u662f\u4e00\u4e2a\u70b9","\u968f\u673a\u70b9\u51fb\u4e00\u4e2a\u4f4d\u7f6e\u662f\u4e3a\u9632\u6b62\u88ab\u88ab\u8ba4\u4e3a\u662f\u673a\u5668\u4eba","\u8fd4\u56de\u5b9e\u9645\u70b9\u51fb\u4f4d\u7f6e"],"function":"def input_tap(self, pos):\n \"\"\"\n \u70b9\u51fb\u5c4f\u5e55\n pos\u4e3a\u4e00\u4e2a\u533a\u57df\u7684\u5de6\u4e0a\u4e0e\u53f3\u4e0b\u5750\u6807\n \u5982\u679c\u4e8b\u5148\u5df2\u7ecf\u968f\u673a\u5316\u4e86pos\u53ef\u4ee5\u53ea\u662f\u4e00\u4e2a\u70b9 \u968f\u673a\u70b9\u51fb\u4e00\u4e2a\u4f4d\u7f6e\u662f\u4e3a\u9632\u6b62\u88ab\u88ab\u8ba4\u4e3a\u662f\u673a\u5668\u4eba\n \u8fd4\u56de\u5b9e\u9645\u70b9\u51fb\u4f4d\u7f6e\n \"\"\"\n if len(pos) == 2:_pos = pos\n else : _pos = (random.randint(pos[0],pos[2]),random.randint(pos[1],pos[3]))\n command = r'adb -s '+str(self.phone)+' shell input tap {} {}'.format(_pos[0],_pos[1])\n system(command)\n return _pos","function_tokens":["def","input_tap","(","self",",","pos",")",":","if","len","(","pos",")","==","2",":","_pos","=","pos","else",":","_pos","=","(","random",".","randint","(","pos","[","0","]",",","pos","[","2","]",")",",","random",".","randint","(","pos","[","1","]",",","pos","[","3","]",")",")","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell input tap {} {}'",".","format","(","_pos","[","0","]",",","_pos","[","1","]",")","system","(","command",")","return","_pos"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L41-L52"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_swipe","parameters":"(self, x1, x2)","argument_list":"","return_statement":"return [x1,x2]","docstring":"\u4ece\u4e00\u4e2a\u4f4d\u7f6e\u6ed1\u52a8\u5230\u53e6\u4e00\u4f4d\u7f6e\n :param x1:\u8d77\u59cb\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :param x2:\u7ec8\u70b9\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:[x1,x2]","docstring_summary":"\u4ece\u4e00\u4e2a\u4f4d\u7f6e\u6ed1\u52a8\u5230\u53e6\u4e00\u4f4d\u7f6e\n :param x1:\u8d77\u59cb\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :param x2:\u7ec8\u70b9\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:[x1,x2]","docstring_tokens":["\u4ece\u4e00\u4e2a\u4f4d\u7f6e\u6ed1\u52a8\u5230\u53e6\u4e00\u4f4d\u7f6e",":","param","x1",":","\u8d77\u59cb\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9",":","param","x2",":","\u7ec8\u70b9\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9",":","return",":","[","x1","x2","]"],"function":"def input_swipe(self, x1, x2):\n \"\"\"\n \u4ece\u4e00\u4e2a\u4f4d\u7f6e\u6ed1\u52a8\u5230\u53e6\u4e00\u4f4d\u7f6e\n :param x1:\u8d77\u59cb\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :param x2:\u7ec8\u70b9\u5750\u6807\uff0c\u5c4f\u5e55\u5de6\u4e0a\u89d2\u4e3a\u539f\u70b9\n :return:[x1,x2]\n \"\"\"\n command = r'adb -s '+str(self.phone)+' shell input swipe {} {} {} {}'.format(x1[0],x1[1],x2[0],x2[1])\n system(command)\n return [x1,x2]","function_tokens":["def","input_swipe","(","self",",","x1",",","x2",")",":","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell input swipe {} {} {} {}'",".","format","(","x1","[","0","]",",","x1","[","1","]",",","x2","[","0","]",",","x2","[","1","]",")","system","(","command",")","return","[","x1",",","x2","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L55-L64"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_roll","parameters":"(self, dx=0, dy=500)","argument_list":"","return_statement":"return [dx,dy]","docstring":"\u62c9\u52a8\u5c4f\u5e55\n :param dx:x\u65b9\u5411\u901f\u5ea6\n :param dy:y\u65b9\u5411\u901f\u5ea6\n :return:[dx, dy]","docstring_summary":"\u62c9\u52a8\u5c4f\u5e55\n :param dx:x\u65b9\u5411\u901f\u5ea6\n :param dy:y\u65b9\u5411\u901f\u5ea6\n :return:[dx, dy]","docstring_tokens":["\u62c9\u52a8\u5c4f\u5e55",":","param","dx",":","x\u65b9\u5411\u901f\u5ea6",":","param","dy",":","y\u65b9\u5411\u901f\u5ea6",":","return",":","[","dx","dy","]"],"function":"def input_roll(self, dx=0, dy=500):\n \"\"\"\n \u62c9\u52a8\u5c4f\u5e55\n :param dx:x\u65b9\u5411\u901f\u5ea6\n :param dy:y\u65b9\u5411\u901f\u5ea6\n :return:[dx, dy]\n \"\"\"\n command = r'adb -s '+str(self.phone)+' shell input roll {} {}'.format(dx,dy)\n system(command)\n return [dx,dy]","function_tokens":["def","input_roll","(","self",",","dx","=","0",",","dy","=","500",")",":","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell input roll {} {}'",".","format","(","dx",",","dy",")","system","(","command",")","return","[","dx",",","dy","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L67-L76"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_key_event","parameters":"(self, event_cmd)","argument_list":"","return_statement":"return event_cmd","docstring":"\u6309\u952e\u4e8b\u4ef6 \u6bd4\u5982home menue back volum_up volum_down\u7b49\u7b49 \u5177\u4f53\u5b9a\u4e49\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\n :param event_cmd:\u4e8b\u4ef6ID\n :return:event_cmd","docstring_summary":"\u6309\u952e\u4e8b\u4ef6 \u6bd4\u5982home menue back volum_up volum_down\u7b49\u7b49 \u5177\u4f53\u5b9a\u4e49\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\n :param event_cmd:\u4e8b\u4ef6ID\n :return:event_cmd","docstring_tokens":["\u6309\u952e\u4e8b\u4ef6","\u6bd4\u5982home","menue","back","volum_up","volum_down\u7b49\u7b49","\u5177\u4f53\u5b9a\u4e49\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d",":","param","event_cmd",":","\u4e8b\u4ef6ID",":","return",":","event_cmd"],"function":"def input_key_event(self, event_cmd):\n \"\"\"\n \u6309\u952e\u4e8b\u4ef6 \u6bd4\u5982home menue back volum_up volum_down\u7b49\u7b49 \u5177\u4f53\u5b9a\u4e49\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\n :param event_cmd:\u4e8b\u4ef6ID\n :return:event_cmd\n \"\"\"\n command = r'adb -s '+str(self.phone)+' shell input keyevent '+event_cmd\n system(command)\n return event_cmd","function_tokens":["def","input_key_event","(","self",",","event_cmd",")",":","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell input keyevent '","+","event_cmd","system","(","command",")","return","event_cmd"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L79-L87"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_text","parameters":"(self, text)","argument_list":"","return_statement":"return text","docstring":"\u8f93\u5165\u6587\u672c\u4fe1\u606f \u53ef\u80fd\u4e0d\u652f\u6301\u4e2d\u6587\u8f93\u5165\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f","docstring_summary":"\u8f93\u5165\u6587\u672c\u4fe1\u606f \u53ef\u80fd\u4e0d\u652f\u6301\u4e2d\u6587\u8f93\u5165\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f","docstring_tokens":["\u8f93\u5165\u6587\u672c\u4fe1\u606f","\u53ef\u80fd\u4e0d\u652f\u6301\u4e2d\u6587\u8f93\u5165",":","param","text",":","\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f",":","return",":","\u6587\u672c\u4fe1\u606f"],"function":"def input_text(self, text):\n \"\"\"\n \u8f93\u5165\u6587\u672c\u4fe1\u606f \u53ef\u80fd\u4e0d\u652f\u6301\u4e2d\u6587\u8f93\u5165\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f\n \"\"\"\n command = r'adb -s '+str(self.phone)+' shell input text {}'.format(text)\n system(command)\n return text","function_tokens":["def","input_text","(","self",",","text",")",":","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell input text {}'",".","format","(","text",")","system","(","command",")","return","text"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L90-L98"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"PhoneControl.input_chn","parameters":"(self, text)","argument_list":"","return_statement":"return text","docstring":"\u652f\u6301\u4e2d\u6587 \u9700\u8981\u4e8b\u5148\u5c06ADB\u952e\u76d8\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u8f93\u5165\u6cd5\u800c\u4e14\u6253\u5f00\u8f6f\u952e\u76d8\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f","docstring_summary":"\u652f\u6301\u4e2d\u6587 \u9700\u8981\u4e8b\u5148\u5c06ADB\u952e\u76d8\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u8f93\u5165\u6cd5\u800c\u4e14\u6253\u5f00\u8f6f\u952e\u76d8\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f","docstring_tokens":["\u652f\u6301\u4e2d\u6587","\u9700\u8981\u4e8b\u5148\u5c06ADB\u952e\u76d8\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u8f93\u5165\u6cd5\u800c\u4e14\u6253\u5f00\u8f6f\u952e\u76d8",":","param","text",":","\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f",":","return",":","\u6587\u672c\u4fe1\u606f"],"function":"def input_chn(self, text):\n \"\"\"\n \u652f\u6301\u4e2d\u6587 \u9700\u8981\u4e8b\u5148\u5c06ADB\u952e\u76d8\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u8f93\u5165\u6cd5\u800c\u4e14\u6253\u5f00\u8f6f\u952e\u76d8\n :param text:\u5f85\u8f93\u5165\u7684\u6587\u672c\u4fe1\u606f\n :return:\u6587\u672c\u4fe1\u606f\n \"\"\"\n # adb -s 127.0.0.1:62001 shell am broadcast -a ADB_INPUT_TEXT --es msg \"\u5a01\u6b66\u4e4b\u5e08\"\n # command = r'adb -s '+str(self.phone)+' shell am broadcast -a ADB_INPUT_TEXT --es msg {}'.format(text)\n command = r'adb -s '+str(self.phone)+' shell am broadcast -a ADB_INPUT_TEXT --es msg {}'.format(text)\n system(command)\n return text","function_tokens":["def","input_chn","(","self",",","text",")",":","# adb -s 127.0.0.1:62001 shell am broadcast -a ADB_INPUT_TEXT --es msg \"\u5a01\u6b66\u4e4b\u5e08\"","# command = r'adb -s '+str(self.phone)+' shell am broadcast -a ADB_INPUT_TEXT --es msg {}'.format(text)","command","=","r'adb -s '","+","str","(","self",".","phone",")","+","' shell am broadcast -a ADB_INPUT_TEXT --es msg {}'",".","format","(","text",")","system","(","command",")","return","text"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L101-L111"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"OperateAllPhone.__init__","parameters":"(self, phone_list)","argument_list":"","return_statement":"","docstring":":param phone_list:","docstring_summary":":param phone_list:","docstring_tokens":[":","param","phone_list",":"],"function":"def __init__(self, phone_list):\n \"\"\"\n :param phone_list:\n \"\"\"\n self.phone_list = phone_list\n self.pcs = []\n for ap in self.phone_list:\n self.pcs.append(PhoneControl(ap))","function_tokens":["def","__init__","(","self",",","phone_list",")",":","self",".","phone_list","=","phone_list","self",".","pcs","=","[","]","for","ap","in","self",".","phone_list",":","self",".","pcs",".","append","(","PhoneControl","(","ap",")",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L118-L125"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/PhoneControl.py","language":"python","identifier":"OperateAllPhone.operate_all","parameters":"(self, operation, args)","argument_list":"","return_statement":"return operation","docstring":":param operation: PhoneControl\u5b9e\u4f8b\u65b9\u6cd5\u5b57\u7b26\u4e32\u540d\u79f0\n :param args:tuple\u683c\u5f0f\u53c2\u6570\n :return:","docstring_summary":":param operation: PhoneControl\u5b9e\u4f8b\u65b9\u6cd5\u5b57\u7b26\u4e32\u540d\u79f0\n :param args:tuple\u683c\u5f0f\u53c2\u6570\n :return:","docstring_tokens":[":","param","operation",":","PhoneControl\u5b9e\u4f8b\u65b9\u6cd5\u5b57\u7b26\u4e32\u540d\u79f0",":","param","args",":","tuple\u683c\u5f0f\u53c2\u6570",":","return",":"],"function":"def operate_all(self, operation, args):\n \"\"\"\n :param operation: PhoneControl\u5b9e\u4f8b\u65b9\u6cd5\u5b57\u7b26\u4e32\u540d\u79f0\n :param args:tuple\u683c\u5f0f\u53c2\u6570\n :return:\n \"\"\"\n _tasks = []\n for pc in self.pcs:\n _tasks.append(Thread(target=pc.__getattribute__(operation), args=args))\n for t in _tasks:\n t.start()\n for t in _tasks:\n t.join()\n return operation","function_tokens":["def","operate_all","(","self",",","operation",",","args",")",":","_tasks","=","[","]","for","pc","in","self",".","pcs",":","_tasks",".","append","(","Thread","(","target","=","pc",".","__getattribute__","(","operation",")",",","args","=","args",")",")","for","t","in","_tasks",":","t",".","start","(",")","for","t","in","_tasks",":","t",".","join","(",")","return","operation"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/PhoneControl.py#L166-L179"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/OCR.py","language":"python","identifier":"OCR.get_file_content","parameters":"(filePath)","argument_list":"","return_statement":"","docstring":":param filePath: \u6587\u4ef6\u5730\u5740\n :return: \u8bfb\u53d6\u7684\u56fe\u7247\u6587\u4ef6","docstring_summary":":param filePath: \u6587\u4ef6\u5730\u5740\n :return: \u8bfb\u53d6\u7684\u56fe\u7247\u6587\u4ef6","docstring_tokens":[":","param","filePath",":","\u6587\u4ef6\u5730\u5740",":","return",":","\u8bfb\u53d6\u7684\u56fe\u7247\u6587\u4ef6"],"function":"def get_file_content(filePath):\n \"\"\"\n :param filePath: \u6587\u4ef6\u5730\u5740\n :return: \u8bfb\u53d6\u7684\u56fe\u7247\u6587\u4ef6\n \"\"\"\n with open(filePath, 'rb') as fp:\n return fp.read()","function_tokens":["def","get_file_content","(","filePath",")",":","with","open","(","filePath",",","'rb'",")","as","fp",":","return","fp",".","read","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/OCR.py#L14-L20"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/OCR.py","language":"python","identifier":"OCR.pre_process_img","parameters":"(pic_file_name, quality=50, crop=None)","argument_list":"","return_statement":"return pic_file_name+'.jpg'","docstring":":param pic_file_name:\u5f85\u538b\u7f29\u56fe\u7247\u540d\u79f0\n :param quality:\u8d28\u91cf\u767e\u5206\u6570\n :param crop:(left, top, right, bottom)\u88c1\u526a\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u7edd\u5bf9\u5750\u6807\n :return: \u538b\u7f29\u56fe\u7247\u5e76\u4e14\u8fd4\u56de\u538b\u7f29\u53ea\u6709\u56fe\u7247\u7684\u540d\u79f0","docstring_summary":":param pic_file_name:\u5f85\u538b\u7f29\u56fe\u7247\u540d\u79f0\n :param quality:\u8d28\u91cf\u767e\u5206\u6570\n :param crop:(left, top, right, bottom)\u88c1\u526a\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u7edd\u5bf9\u5750\u6807\n :return: \u538b\u7f29\u56fe\u7247\u5e76\u4e14\u8fd4\u56de\u538b\u7f29\u53ea\u6709\u56fe\u7247\u7684\u540d\u79f0","docstring_tokens":[":","param","pic_file_name",":","\u5f85\u538b\u7f29\u56fe\u7247\u540d\u79f0",":","param","quality",":","\u8d28\u91cf\u767e\u5206\u6570",":","param","crop",":","(","left","top","right","bottom",")","\u88c1\u526a\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u7edd\u5bf9\u5750\u6807",":","return",":","\u538b\u7f29\u56fe\u7247\u5e76\u4e14\u8fd4\u56de\u538b\u7f29\u53ea\u6709\u56fe\u7247\u7684\u540d\u79f0"],"function":"def pre_process_img(pic_file_name, quality=50, crop=None):\n \"\"\"\n :param pic_file_name:\u5f85\u538b\u7f29\u56fe\u7247\u540d\u79f0\n :param quality:\u8d28\u91cf\u767e\u5206\u6570\n :param crop:(left, top, right, bottom)\u88c1\u526a\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u7edd\u5bf9\u5750\u6807\n :return: \u538b\u7f29\u56fe\u7247\u5e76\u4e14\u8fd4\u56de\u538b\u7f29\u53ea\u6709\u56fe\u7247\u7684\u540d\u79f0\n \"\"\"\n im = Image.open(pic_file_name)\n rgb_im = im.convert('RGB')\n if crop:\n rgb_im = rgb_im.crop(crop)\n rgb_im.save(pic_file_name+'.jpg', optimize=True, quality=quality)\n return pic_file_name+'.jpg'","function_tokens":["def","pre_process_img","(","pic_file_name",",","quality","=","50",",","crop","=","None",")",":","im","=","Image",".","open","(","pic_file_name",")","rgb_im","=","im",".","convert","(","'RGB'",")","if","crop",":","rgb_im","=","rgb_im",".","crop","(","crop",")","rgb_im",".","save","(","pic_file_name","+","'.jpg'",",","optimize","=","True",",","quality","=","quality",")","return","pic_file_name","+","'.jpg'"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/OCR.py#L23-L35"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/OCR.py","language":"python","identifier":"OCR.ocr","parameters":"(pic_file_name, location=False, quality=50, crop=None)","argument_list":"","return_statement":"","docstring":"\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\u8c03\u7528API\u8fd4\u56decor\u7ed3\u679c\n :param pic_file_name:\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\n :param location:\u662f\u5426\u9700\u8981\u8bc6\u522b\u4f4d\u7f6e\u4fe1\u606f \u9700\u8981\u4f4d\u7f6e\u4fe1\u606f True \u8868\u793a\u9700\u8981\n :return:\n \u6709\u4f4d\u7f6e\u4fe1\u606f\n [{'location': {'height': 59,'left': 38,'top': 827,'width': 432},\n 'words': '\u7f51\u9648\u82cf\u82cf:[\u94fe\u63a5]'},\n {'location': {'height': 56,'left': 212,'top': 955,'width': 206},\n 'words': '\u670d\u52a1\u901a\u77e5'},...]\n \u65e0\u4f4d\u7f6e\u4fe1\u606f\n [{'words': '\u5fae\u4fe1'},\n {'words': '\u901a\u8baf\u5f55'},\n {'words': '\u53d1\u73b0'},\n {'words': '\u6211'}],...\n ]","docstring_summary":"\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\u8c03\u7528API\u8fd4\u56decor\u7ed3\u679c\n :param pic_file_name:\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\n :param location:\u662f\u5426\u9700\u8981\u8bc6\u522b\u4f4d\u7f6e\u4fe1\u606f \u9700\u8981\u4f4d\u7f6e\u4fe1\u606f True \u8868\u793a\u9700\u8981\n :return:\n \u6709\u4f4d\u7f6e\u4fe1\u606f\n [{'location': {'height': 59,'left': 38,'top': 827,'width': 432},\n 'words': '\u7f51\u9648\u82cf\u82cf:[\u94fe\u63a5]'},\n {'location': {'height': 56,'left': 212,'top': 955,'width': 206},\n 'words': '\u670d\u52a1\u901a\u77e5'},...]\n \u65e0\u4f4d\u7f6e\u4fe1\u606f\n [{'words': '\u5fae\u4fe1'},\n {'words': '\u901a\u8baf\u5f55'},\n {'words': '\u53d1\u73b0'},\n {'words': '\u6211'}],...\n ]","docstring_tokens":["\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\u8c03\u7528API\u8fd4\u56decor\u7ed3\u679c",":","param","pic_file_name",":","\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d",":","param","location",":","\u662f\u5426\u9700\u8981\u8bc6\u522b\u4f4d\u7f6e\u4fe1\u606f","\u9700\u8981\u4f4d\u7f6e\u4fe1\u606f","True","\u8868\u793a\u9700\u8981",":","return",":","\u6709\u4f4d\u7f6e\u4fe1\u606f","[","{","location",":","{","height",":","59","left",":","38","top",":","827","width",":","432","}","words",":","\u7f51\u9648\u82cf\u82cf",":","[","\u94fe\u63a5","]","}","{","location",":","{","height",":","56","left",":","212","top",":","955","width",":","206","}","words",":","\u670d\u52a1\u901a\u77e5","}","...","]","\u65e0\u4f4d\u7f6e\u4fe1\u606f","[","{","words",":","\u5fae\u4fe1","}","{","words",":","\u901a\u8baf\u5f55","}","{","words",":","\u53d1\u73b0","}","{","words",":","\u6211","}","]","...","]"],"function":"def ocr(pic_file_name, location=False, quality=50, crop=None):\n \"\"\"\n \u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\u8c03\u7528API\u8fd4\u56decor\u7ed3\u679c\n :param pic_file_name:\u6839\u636e\u5305\u542b\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\u540d\n :param location:\u662f\u5426\u9700\u8981\u8bc6\u522b\u4f4d\u7f6e\u4fe1\u606f \u9700\u8981\u4f4d\u7f6e\u4fe1\u606f True \u8868\u793a\u9700\u8981\n :return:\n \u6709\u4f4d\u7f6e\u4fe1\u606f\n [{'location': {'height': 59,'left': 38,'top': 827,'width': 432},\n 'words': '\u7f51\u9648\u82cf\u82cf:[\u94fe\u63a5]'},\n {'location': {'height': 56,'left': 212,'top': 955,'width': 206},\n 'words': '\u670d\u52a1\u901a\u77e5'},...]\n \u65e0\u4f4d\u7f6e\u4fe1\u606f\n [{'words': '\u5fae\u4fe1'},\n {'words': '\u901a\u8baf\u5f55'},\n {'words': '\u53d1\u73b0'},\n {'words': '\u6211'}],...\n ]\n \"\"\"\n compressed_image = OCR.pre_process_img(pic_file_name,quality=quality,crop=crop)\n image = OCR.get_file_content(compressed_image)\n # \u5e26\u6709\u4f4d\u7f6e\u4fe1\u606f\n if location:\n try:\n result = client.general(image)\n except Exception as e:\n logging.error(\"\u8bf7\u6c42 \u5e26\u4f4d\u7f6e\u4fe1\u606f OCR\u5931\u8d25 \u8bf7\u68c0\u67e5\u7f51\u7edc\u6216API\u53ef\u7528\u6b21\u6570\")\n exit()\n # \u8ba1\u7b97words\u88c1\u526a\u4e4b\u524d\u7684\u771f\u662f\u5750\u6807\n if crop:\n for words in result['words_result']:\n words['location']['left'] += crop[0]\n words['location']['top'] += crop[1]\n # \u4e0d\u5e26\u4f4d\u7f6e\u4fe1\u606f\n else:\n try:\n result = client.basicGeneral(image)\n except Exception as e:\n logging.error(\"\u8bf7\u6c42 \u975e\u4f4d\u7f6e\u4fe1\u606f OCR\u5931\u8d25 \u8bf7\u68c0\u67e5\u7f51\u7edc\u6216API\u53ef\u7528\u6b21\u6570\")\n exit()\n if result['words_result_num'] != 0:\n return result['words_result']\n else:\n return OCR_NO_WORDS","function_tokens":["def","ocr","(","pic_file_name",",","location","=","False",",","quality","=","50",",","crop","=","None",")",":","compressed_image","=","OCR",".","pre_process_img","(","pic_file_name",",","quality","=","quality",",","crop","=","crop",")","image","=","OCR",".","get_file_content","(","compressed_image",")","# \u5e26\u6709\u4f4d\u7f6e\u4fe1\u606f","if","location",":","try",":","result","=","client",".","general","(","image",")","except","Exception","as","e",":","logging",".","error","(","\"\u8bf7\u6c42 \u5e26\u4f4d\u7f6e\u4fe1\u606f OCR\u5931\u8d25 \u8bf7\u68c0\u67e5\u7f51\u7edc\u6216API\u53ef\u7528\u6b21\u6570\")","","exit","(",")","# \u8ba1\u7b97words\u88c1\u526a\u4e4b\u524d\u7684\u771f\u662f\u5750\u6807","if","crop",":","for","words","in","result","[","'words_result'","]",":","words","[","'location'","]","[","'left'","]","+=","crop","[","0","]","words","[","'location'","]","[","'top'","]","+=","crop","[","1","]","# \u4e0d\u5e26\u4f4d\u7f6e\u4fe1\u606f","else",":","try",":","result","=","client",".","basicGeneral","(","image",")","except","Exception","as","e",":","logging",".","error","(","\"\u8bf7\u6c42 \u975e\u4f4d\u7f6e\u4fe1\u606f OCR\u5931\u8d25 \u8bf7\u68c0\u67e5\u7f51\u7edc\u6216API\u53ef\u7528\u6b21\u6570\")","","exit","(",")","if","result","[","'words_result_num'","]","!=","0",":","return","result","[","'words_result'","]","else",":","return","OCR_NO_WORDS"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/OCR.py#L38-L80"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.home","parameters":"(self)","argument_list":"","return_statement":"return KEY['BACK_KEYEVENT']","docstring":":return:\u901a\u8fc7\u591a\u6b21\u70b9\u51fbBACK\u6309\u952e\u56de\u5230\u4e3b\u754c\u9762 \u4e4b\u6240\u4ee5\u4e0d\u76f4\u63a5\u70b9\u51fbHOME\u6309\u952e \u662f\u9700\u8981\u5c42\u5c42\u8fd4\u56de\u5fae\u4fe1\u5230\u4e3b\u754c\u9762","docstring_summary":":return:\u901a\u8fc7\u591a\u6b21\u70b9\u51fbBACK\u6309\u952e\u56de\u5230\u4e3b\u754c\u9762 \u4e4b\u6240\u4ee5\u4e0d\u76f4\u63a5\u70b9\u51fbHOME\u6309\u952e \u662f\u9700\u8981\u5c42\u5c42\u8fd4\u56de\u5fae\u4fe1\u5230\u4e3b\u754c\u9762","docstring_tokens":[":","return",":","\u901a\u8fc7\u591a\u6b21\u70b9\u51fbBACK\u6309\u952e\u56de\u5230\u4e3b\u754c\u9762","\u4e4b\u6240\u4ee5\u4e0d\u76f4\u63a5\u70b9\u51fbHOME\u6309\u952e","\u662f\u9700\u8981\u5c42\u5c42\u8fd4\u56de\u5fae\u4fe1\u5230\u4e3b\u754c\u9762"],"function":"def home(self):\n \"\"\"\n :return:\u901a\u8fc7\u591a\u6b21\u70b9\u51fbBACK\u6309\u952e\u56de\u5230\u4e3b\u754c\u9762 \u4e4b\u6240\u4ee5\u4e0d\u76f4\u63a5\u70b9\u51fbHOME\u6309\u952e \u662f\u9700\u8981\u5c42\u5c42\u8fd4\u56de\u5fae\u4fe1\u5230\u4e3b\u754c\u9762\n \"\"\"\n for i in range(7):\n self.oap.key(KEY['BACK_KEYEVENT'])\n time.sleep(0.3)\n return KEY['BACK_KEYEVENT']","function_tokens":["def","home","(","self",")",":","for","i","in","range","(","7",")",":","self",".","oap",".","key","(","KEY","[","'BACK_KEYEVENT'","]",")","time",".","sleep","(","0.3",")","return","KEY","[","'BACK_KEYEVENT'","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L25-L32"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.home_to_gzh_search","parameters":"(self)","argument_list":"","return_statement":"return 0","docstring":":return:\u4ece\u4e3b\u754c\u9762\u5230\u516c\u4f17\u53f7\u641c\u7d22","docstring_summary":":return:\u4ece\u4e3b\u754c\u9762\u5230\u516c\u4f17\u53f7\u641c\u7d22","docstring_tokens":[":","return",":","\u4ece\u4e3b\u754c\u9762\u5230\u516c\u4f17\u53f7\u641c\u7d22"],"function":"def home_to_gzh_search(self):\n \"\"\"\n :return:\u4ece\u4e3b\u754c\u9762\u5230\u516c\u4f17\u53f7\u641c\u7d22\n \"\"\"\n # \u70b9\u51fb\u5fae\u4fe1\u56fe\u6807\n self.oap.tap(BTN['EMU_WEIXIN_ICON'])\n time.sleep(0.5)\n # \u70b9\u51fb\u901a\u4fe1\u5f55\n self.oap.tap(BTN['TONGXUNLU_BTN'])\n time.sleep(0.5)\n # \u70b9\u51fb\u516c\u4f17\u53f7\n self.oap.tap(BTN['GZH_FOLDER'])\n time.sleep(0.5)\n # \u70b9\u51fb\u641c\u7d22\n self.oap.tap(BTN['SEARCH_BTN'])\n time.sleep(1)\n return 0","function_tokens":["def","home_to_gzh_search","(","self",")",":","# \u70b9\u51fb\u5fae\u4fe1\u56fe\u6807","self",".","oap",".","tap","(","BTN","[","'EMU_WEIXIN_ICON'","]",")","time",".","sleep","(","0.5",")","# \u70b9\u51fb\u901a\u4fe1\u5f55","self",".","oap",".","tap","(","BTN","[","'TONGXUNLU_BTN'","]",")","time",".","sleep","(","0.5",")","# \u70b9\u51fb\u516c\u4f17\u53f7","self",".","oap",".","tap","(","BTN","[","'GZH_FOLDER'","]",")","time",".","sleep","(","0.5",")","# \u70b9\u51fb\u641c\u7d22","self",".","oap",".","tap","(","BTN","[","'SEARCH_BTN'","]",")","time",".","sleep","(","1",")","return","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L34-L50"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.search_gzh","parameters":"(self, nickname)","argument_list":"","return_statement":"return 0","docstring":":param nickname:\u5f85\u641c\u7d22\u516c\u4f17\u53f7\u540d\u79f0\n :return:","docstring_summary":":param nickname:\u5f85\u641c\u7d22\u516c\u4f17\u53f7\u540d\u79f0\n :return:","docstring_tokens":[":","param","nickname",":","\u5f85\u641c\u7d22\u516c\u4f17\u53f7\u540d\u79f0",":","return",":"],"function":"def search_gzh(self, nickname):\n \"\"\"\n :param nickname:\u5f85\u641c\u7d22\u516c\u4f17\u53f7\u540d\u79f0\n :return:\n \"\"\"\n # \u8f93\u5165\u62fc\u97f3\n self.oap.text(nickname)\n time.sleep(0.5)\n # \u8fdb\u5165\u8d26\u53f7\n self.oap.tap(BTN['FIRST_GZH_SEARCH_RESULT'])\n time.sleep(0.5)\n #\u952e\u5165\u4e3b\u754c\u9762\n self.oap.tap(BTN['PROFILE_BTN'])\n time.sleep(0.5)\n # \u4e0a\u62c9\n self.oap.roll(0,500)\n time.sleep(0.5)\n return 0","function_tokens":["def","search_gzh","(","self",",","nickname",")",":","# \u8f93\u5165\u62fc\u97f3","self",".","oap",".","text","(","nickname",")","time",".","sleep","(","0.5",")","# \u8fdb\u5165\u8d26\u53f7","self",".","oap",".","tap","(","BTN","[","'FIRST_GZH_SEARCH_RESULT'","]",")","time",".","sleep","(","0.5",")","#\u952e\u5165\u4e3b\u754c\u9762","self",".","oap",".","tap","(","BTN","[","'PROFILE_BTN'","]",")","time",".","sleep","(","0.5",")","# \u4e0a\u62c9","self",".","oap",".","roll","(","0",",","500",")","time",".","sleep","(","0.5",")","return","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L52-L69"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.all_message","parameters":"(self)","argument_list":"","return_statement":"return 0","docstring":":return:\u4ece\u516c\u4f17\u53f7\u4e3b\u9875\u4e0b\u62c9\u70b9\u51fb\u5168\u90e8\u6d88\u606f\u6d88\u606f","docstring_summary":":return:\u4ece\u516c\u4f17\u53f7\u4e3b\u9875\u4e0b\u62c9\u70b9\u51fb\u5168\u90e8\u6d88\u606f\u6d88\u606f","docstring_tokens":[":","return",":","\u4ece\u516c\u4f17\u53f7\u4e3b\u9875\u4e0b\u62c9\u70b9\u51fb\u5168\u90e8\u6d88\u606f\u6d88\u606f"],"function":"def all_message(self):\n \"\"\"\n :return:\u4ece\u516c\u4f17\u53f7\u4e3b\u9875\u4e0b\u62c9\u70b9\u51fb\u5168\u90e8\u6d88\u606f\u6d88\u606f\n \"\"\"\n # \u5168\u90e8\u6d88\u606f\n all_message_pos = self.vc.click_by_words(\"\u5168\u90e8\u6d88\u606f\",tap=False)\n self.oap.tap(all_message_pos)\n time.sleep(5)\n self.oap.roll(0,500)\n time.sleep(2)\n return 0","function_tokens":["def","all_message","(","self",")",":","# \u5168\u90e8\u6d88\u606f","all_message_pos","=","self",".","vc",".","click_by_words","(","\"\u5168\u90e8\u6d88\u606f\",tap=Fal","s","e)","","","","self",".","oap",".","tap","(","all_message_pos",")","time",".","sleep","(","5",")","self",".","oap",".","roll","(","0",",","500",")","time",".","sleep","(","2",")","return","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L71-L81"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.click_a_message","parameters":"(self, args=2)","argument_list":"","return_statement":"","docstring":":return:\u6765\u5230\u5386\u53f2\u5217\u8868\u4e4b\u540e\u968f\u673a\u70b9\u51fb\u4e00\u7bc7\u6587\u7ae0","docstring_summary":":return:\u6765\u5230\u5386\u53f2\u5217\u8868\u4e4b\u540e\u968f\u673a\u70b9\u51fb\u4e00\u7bc7\u6587\u7ae0","docstring_tokens":[":","return",":","\u6765\u5230\u5386\u53f2\u5217\u8868\u4e4b\u540e\u968f\u673a\u70b9\u51fb\u4e00\u7bc7\u6587\u7ae0"],"function":"def click_a_message(self, args=2):\n \"\"\"\n :return:\u6765\u5230\u5386\u53f2\u5217\u8868\u4e4b\u540e\u968f\u673a\u70b9\u51fb\u4e00\u7bc7\u6587\u7ae0\n \"\"\"\n #\u83b7\u53d6\u754c\u9762\u6587\u7ae0\u6807\u9898\u6d88\u606f\n if args==1:corp = CROP_RANGE['PROFILE_MESSAGE_LIST']\n elif args==2:corp = CROP_RANGE['MESSAGE_LIST']\n ui_words = self.vc.get_ui_words(location=True, crop=corp)\n #\u968f\u4fbf\u70b9\u4e00\u4e2a\u6807\u9898\n random_index = randint(1,len(ui_words))-1\n loc = ui_words[random_index]['location']\n pos = [loc['left'],loc['top'],loc['left']+loc['width'],loc['top']+loc['height']]\n self.oap.tap(pos)\n #\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6bd5\n time.sleep(5)\n self.oap.roll(0,500)\n time.sleep(1)","function_tokens":["def","click_a_message","(","self",",","args","=","2",")",":","#\u83b7\u53d6\u754c\u9762\u6587\u7ae0\u6807\u9898\u6d88\u606f","if","args","==","1",":","corp","=","CROP_RANGE","[","'PROFILE_MESSAGE_LIST'","]","elif","args","==","2",":","corp","=","CROP_RANGE","[","'MESSAGE_LIST'","]","ui_words","=","self",".","vc",".","get_ui_words","(","location","=","True",",","crop","=","corp",")","#\u968f\u4fbf\u70b9\u4e00\u4e2a\u6807\u9898","random_index","=","randint","(","1",",","len","(","ui_words",")",")","-","1","loc","=","ui_words","[","random_index","]","[","'location'","]","pos","=","[","loc","[","'left'","]",",","loc","[","'top'","]",",","loc","[","'left'","]","+","loc","[","'width'","]",",","loc","[","'top'","]","+","loc","[","'height'","]","]","self",".","oap",".","tap","(","pos",")","#\u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6bd5","time",".","sleep","(","5",")","self",".","oap",".","roll","(","0",",","500",")","time",".","sleep","(","1",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L83-L99"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.check_comments","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u6210\u529f\u6253\u5f00\u4e00\u7bc7\u6587\u7ae0\u4e4b\u540e \u62c9\u5230\u5e95\u68c0\u67e5\u8bc4\u8bba\u4fe1\u606f","docstring_summary":":return:\u6210\u529f\u6253\u5f00\u4e00\u7bc7\u6587\u7ae0\u4e4b\u540e \u62c9\u5230\u5e95\u68c0\u67e5\u8bc4\u8bba\u4fe1\u606f","docstring_tokens":[":","return",":","\u6210\u529f\u6253\u5f00\u4e00\u7bc7\u6587\u7ae0\u4e4b\u540e","\u62c9\u5230\u5e95\u68c0\u67e5\u8bc4\u8bba\u4fe1\u606f"],"function":"def check_comments(self):\n \"\"\"\n :return:\u6210\u529f\u6253\u5f00\u4e00\u7bc7\u6587\u7ae0\u4e4b\u540e \u62c9\u5230\u5e95\u68c0\u67e5\u8bc4\u8bba\u4fe1\u606f\n \"\"\"\n # \u62c9\u5230\u5e95\n for i in range(2):\n self.oap.roll(0,500)\n time.sleep(1)\n time.sleep(2)\n # \u68c0\u67e5\u6709\u65e0\u8bc4\u8bba \u6709\u8bc4\u8bba \u65e0\u8bc4\u8bba \u6709\u5e7f\u544a \u4e09\u79cd\u60c5\u51b5\n ui_words_str = self.vc.get_ui_words(location=False,in_str=True,crop=CROP_RANGE['LEAVE_MSG_BOTTOM'])\n # \u5982\u679c\u6682\u65e0\u8bc4\u8bba\u70b9\u51fb\u4e86\u7559\u8a00\u6309\u94ae\n if UI_WORDS['NO_LEAVING_MSG'] in ui_words_str:\n print('\u70b9\u51fb\u4e86\u7559\u8a00\u4fe1\u606f\u3002\u3002\u3002')\n self.oap.tap(BTN['LEAVE_MSG'])\n time.sleep(1)\n self.oap.key(KEY['BACK_KEYEVENT'])","function_tokens":["def","check_comments","(","self",")",":","# \u62c9\u5230\u5e95","for","i","in","range","(","2",")",":","self",".","oap",".","roll","(","0",",","500",")","time",".","sleep","(","1",")","time",".","sleep","(","2",")","# \u68c0\u67e5\u6709\u65e0\u8bc4\u8bba \u6709\u8bc4\u8bba \u65e0\u8bc4\u8bba \u6709\u5e7f\u544a \u4e09\u79cd\u60c5\u51b5","ui_words_str","=","self",".","vc",".","get_ui_words","(","location","=","False",",","in_str","=","True",",","crop","=","CROP_RANGE","[","'LEAVE_MSG_BOTTOM'","]",")","# \u5982\u679c\u6682\u65e0\u8bc4\u8bba\u70b9\u51fb\u4e86\u7559\u8a00\u6309\u94ae","if","UI_WORDS","[","'NO_LEAVING_MSG'","]","in","ui_words_str",":","print","(","'\u70b9\u51fb\u4e86\u7559\u8a00\u4fe1\u606f\u3002\u3002\u3002')","","self",".","oap",".","tap","(","BTN","[","'LEAVE_MSG'","]",")","time",".","sleep","(","1",")","self",".","oap",".","key","(","KEY","[","'BACK_KEYEVENT'","]",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L102-L118"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.get_all_req_data","parameters":"(self, nickname, hand=False)","argument_list":"","return_statement":"","docstring":"\u83b7\u53d6\u5173\u4e8e\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u8bf7\u6c42\u6570\u636e \u5f53\u524d\u7a0b\u5e8f\u4f7f\u7528baidu API\u53d7\u5230\u7f51\u7edc\u548c\u5e76\u53d1\u9650\u5236\u6548\u679c\u5e76\u5341\u5206\u7406\u60f3\n :param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e","docstring_summary":"\u83b7\u53d6\u5173\u4e8e\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u8bf7\u6c42\u6570\u636e \u5f53\u524d\u7a0b\u5e8f\u4f7f\u7528baidu API\u53d7\u5230\u7f51\u7edc\u548c\u5e76\u53d1\u9650\u5236\u6548\u679c\u5e76\u5341\u5206\u7406\u60f3\n :param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e","docstring_tokens":["\u83b7\u53d6\u5173\u4e8e\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u8bf7\u6c42\u6570\u636e","\u5f53\u524d\u7a0b\u5e8f\u4f7f\u7528baidu","API\u53d7\u5230\u7f51\u7edc\u548c\u5e76\u53d1\u9650\u5236\u6548\u679c\u5e76\u5341\u5206\u7406\u60f3",":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","return",":","\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e"],"function":"def get_all_req_data(self, nickname, hand=False):\n \"\"\"\n \u83b7\u53d6\u5173\u4e8e\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u8bf7\u6c42\u6570\u636e \u5f53\u524d\u7a0b\u5e8f\u4f7f\u7528baidu API\u53d7\u5230\u7f51\u7edc\u548c\u5e76\u53d1\u9650\u5236\u6548\u679c\u5e76\u5341\u5206\u7406\u60f3\n :param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e\n \"\"\"\n TidyReqData.flush_data(\"*.req\")\n redis_instance.set('current_nickname',nickname)\n self.home_to_gzh_search()\n self.search_gzh(nickname)\n if hand==False:\n self.all_message()\n self.click_a_message()\n # self.check_comments()\n else:\n input(\"\u8bf7\u4e00\u4e00\u624b\u52a8\u6216\u53d6\u53c2\u6570 \u56de\u8f66\u9000\u51fa\")\n self.home()","function_tokens":["def","get_all_req_data","(","self",",","nickname",",","hand","=","False",")",":","TidyReqData",".","flush_data","(","\"*.req\"",")","redis_instance",".","set","(","'current_nickname'",",","nickname",")","self",".","home_to_gzh_search","(",")","self",".","search_gzh","(","nickname",")","if","hand","==","False",":","self",".","all_message","(",")","self",".","click_a_message","(",")","# self.check_comments()","else",":","input","(","\"\u8bf7\u4e00\u4e00\u624b\u52a8\u6216\u53d6\u53c2\u6570 \u56de\u8f66\u9000\u51fa\")","","self",".","home","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L120-L136"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/phone_operate\/WeixinOperate.py","language":"python","identifier":"WeixinOperate.get_part_req_data","parameters":"(self, nickname)","argument_list":"","return_statement":"","docstring":"\u4ec5\u83b7\u53d6\u9605\u8bfb\u91cf\u548c\u8bc4\u8bba\u7684\u8bf7\u6c42\u6570\u636e\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e","docstring_summary":"\u4ec5\u83b7\u53d6\u9605\u8bfb\u91cf\u548c\u8bc4\u8bba\u7684\u8bf7\u6c42\u6570\u636e\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e","docstring_tokens":["\u4ec5\u83b7\u53d6\u9605\u8bfb\u91cf\u548c\u8bc4\u8bba\u7684\u8bf7\u6c42\u6570\u636e",":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","return",":","\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e"],"function":"def get_part_req_data(self, nickname):\n \"\"\"\n \u4ec5\u83b7\u53d6\u9605\u8bfb\u91cf\u548c\u8bc4\u8bba\u7684\u8bf7\u6c42\u6570\u636e\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u6700\u540e\u6210\u529f\u4e0e\u5426\u53d6\u51b3\u5728redis\u4e2d\u662f\u5426\u627e\u5230\u6709\u6709\u6548\u6570\u636e\n \"\"\"\n TidyReqData.flush_data()\n redis_instance.set('current_nickname',nickname)\n self.home_to_gzh_search()\n self.search_gzh(nickname)\n self.click_a_message(args=1)\n self.check_comments()\n self.home()","function_tokens":["def","get_part_req_data","(","self",",","nickname",")",":","TidyReqData",".","flush_data","(",")","redis_instance",".","set","(","'current_nickname'",",","nickname",")","self",".","home_to_gzh_search","(",")","self",".","search_gzh","(","nickname",")","self",".","click_a_message","(","args","=","1",")","self",".","check_comments","(",")","self",".","home","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/phone_operate\/WeixinOperate.py#L138-L150"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/__init__.py","language":"python","identifier":"gzh_crawler","parameters":"(config=2)","argument_list":"","return_statement":"","docstring":":param config:\n 1 \u53ea\u83b7\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\n 2 \u83b7\u53d6\u6587\u7ae0\u5185\u5bb9\u5e76\u8f6c\u5316\u4e3amarkdown\u683c\u5f0f\n 3 \u57282\u7684\u57fa\u7840\u4e0a\u83b7\u53d6\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\u3001\u70b9\u8d5e\u91cf\u3001\u8bc4\u8bba\u91cf\u7b49\u4fe1\u606f\n :return: \u6570\u636e\u5b58\u5165mongodb \u65e0\u8fd4\u56de\u503c","docstring_summary":":param config:\n 1 \u53ea\u83b7\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\n 2 \u83b7\u53d6\u6587\u7ae0\u5185\u5bb9\u5e76\u8f6c\u5316\u4e3amarkdown\u683c\u5f0f\n 3 \u57282\u7684\u57fa\u7840\u4e0a\u83b7\u53d6\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\u3001\u70b9\u8d5e\u91cf\u3001\u8bc4\u8bba\u91cf\u7b49\u4fe1\u606f\n :return: \u6570\u636e\u5b58\u5165mongodb \u65e0\u8fd4\u56de\u503c","docstring_tokens":[":","param","config",":","1","\u53ea\u83b7\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868","2","\u83b7\u53d6\u6587\u7ae0\u5185\u5bb9\u5e76\u8f6c\u5316\u4e3amarkdown\u683c\u5f0f","3","\u57282\u7684\u57fa\u7840\u4e0a\u83b7\u53d6\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\u3001\u70b9\u8d5e\u91cf\u3001\u8bc4\u8bba\u91cf\u7b49\u4fe1\u606f",":","return",":","\u6570\u636e\u5b58\u5165mongodb","\u65e0\u8fd4\u56de\u503c"],"function":"def gzh_crawler(config=2):\n \"\"\"\n :param config:\n 1 \u53ea\u83b7\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\n 2 \u83b7\u53d6\u6587\u7ae0\u5185\u5bb9\u5e76\u8f6c\u5316\u4e3amarkdown\u683c\u5f0f\n 3 \u57282\u7684\u57fa\u7840\u4e0a\u83b7\u53d6\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\u3001\u70b9\u8d5e\u91cf\u3001\u8bc4\u8bba\u91cf\u7b49\u4fe1\u606f\n :return: \u6570\u636e\u5b58\u5165mongodb \u65e0\u8fd4\u56de\u503c\n \"\"\"\n deepth= config\n yield runner.crawl(ArticleListSpider)\n deepth -= 1\n if deepth>0:\n yield runner.crawl(ArticleSpider)\n deepth -= 1\n if deepth>0:\n yield runner.crawl(ArticleReadDataSpider)\n reactor.stop()","function_tokens":["def","gzh_crawler","(","config","=","2",")",":","deepth","=","config","yield","runner",".","crawl","(","ArticleListSpider",")","deepth","-=","1","if","deepth",">","0",":","yield","runner",".","crawl","(","ArticleSpider",")","deepth","-=","1","if","deepth",">","0",":","yield","runner",".","crawl","(","ArticleReadDataSpider",")","reactor",".","stop","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/__init__.py#L11-L27"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/__init__.py","language":"python","identifier":"run_crawl","parameters":"(config=2)","argument_list":"","return_statement":"","docstring":":param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:","docstring_summary":":param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:","docstring_tokens":[":","param","config",":","\u540cgzh_crawler","\u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e",":","return",":"],"function":"def run_crawl(config=2):\n \"\"\"\n :param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:\n \"\"\"\n gzh_crawler(config)\n reactor.run()\n print('\u6240\u6709\u722c\u866b\u7ed3\u675f\u5de5\u4f5c')\n # \u7531\u4e8etwisted reactor\u65e0\u6cd5\u91cd\u65b0\u542f\u52a8 \u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u722c\u53d6\u4efb\u52a1\u7ed3\u675f\u4e4b\u540e\u91cd\u542f\u811a\u672c\n from tools import restart\n restart()","function_tokens":["def","run_crawl","(","config","=","2",")",":","gzh_crawler","(","config",")","reactor",".","run","(",")","print","(","'\u6240\u6709\u722c\u866b\u7ed3\u675f\u5de5\u4f5c')","","# \u7531\u4e8etwisted reactor\u65e0\u6cd5\u91cd\u65b0\u542f\u52a8 \u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u722c\u53d6\u4efb\u52a1\u7ed3\u675f\u4e4b\u540e\u91cd\u542f\u811a\u672c","from","tools","import","restart","restart","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/__init__.py#L30-L40"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/__init__.py","language":"python","identifier":"_run_crawl","parameters":"(config=2)","argument_list":"","return_statement":"","docstring":":param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:","docstring_summary":":param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:","docstring_tokens":[":","param","config",":","\u540cgzh_crawler","\u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e",":","return",":"],"function":"def _run_crawl(config=2):\n \"\"\"\n :param config:\u540cgzh_crawler \u9ed8\u8ba4\u83b7\u53d6\u6587\u7ae0\u7684\u6587\u672c\u6570\u636e\n :return:\n \"\"\"\n from multiprocessing import Process\n p = Process(target=_run_crawl,args=(config,))\n p.start()\n p.join()","function_tokens":["def","_run_crawl","(","config","=","2",")",":","from","multiprocessing","import","Process","p","=","Process","(","target","=","_run_crawl",",","args","=","(","config",",",")",")","p",".","start","(",")","p",".","join","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/__init__.py#L42-L50"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/utils\/__init__.py","language":"python","identifier":"get_global_settings","parameters":"()","argument_list":"","return_statement":"return custom_settings","docstring":":return:\u4ececrapy\u7684\u5168\u5c40\u8bbe\u7f6e\u811a\u672csettings.py\u4e2d\u83b7\u53d6\u6240\u6709\u7684\u8bbe\u7f6e\u6587\u4ef6","docstring_summary":":return:\u4ececrapy\u7684\u5168\u5c40\u8bbe\u7f6e\u811a\u672csettings.py\u4e2d\u83b7\u53d6\u6240\u6709\u7684\u8bbe\u7f6e\u6587\u4ef6","docstring_tokens":[":","return",":","\u4ececrapy\u7684\u5168\u5c40\u8bbe\u7f6e\u811a\u672csettings",".","py\u4e2d\u83b7\u53d6\u6240\u6709\u7684\u8bbe\u7f6e\u6587\u4ef6"],"function":"def get_global_settings():\n \"\"\"\n :return:\u4ececrapy\u7684\u5168\u5c40\u8bbe\u7f6e\u811a\u672csettings.py\u4e2d\u83b7\u53d6\u6240\u6709\u7684\u8bbe\u7f6e\u6587\u4ef6\n \"\"\"\n custom_settings = {}\n keys = [item for item in dir(settings) if not item.startswith(\"__\")]\n for key in keys:\n custom_settings[key] = getattr(settings, key)\n return custom_settings","function_tokens":["def","get_global_settings","(",")",":","custom_settings","=","{","}","keys","=","[","item","for","item","in","dir","(","settings",")","if","not","item",".","startswith","(","\"__\"",")","]","for","key","in","keys",":","custom_settings","[","key","]","=","getattr","(","settings",",","key",")","return","custom_settings"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/utils\/__init__.py#L4-L12"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article_list.py","language":"python","identifier":"ArticleListSpider.__init__","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"","docstring":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_summary":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_tokens":[":","param","args",":",":","param","kwargs",":","\u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570"],"function":"def __init__(self, *args, **kwargs):\n \"\"\"\n :param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570\n \"\"\"\n self.current_nickname = ''","function_tokens":["def","__init__","(","self",",","*","args",",","*","*","kwargs",")",":","self",".","current_nickname","=","''"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article_list.py#L27-L33"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article_list.py","language":"python","identifier":"ArticleListSpider.start_requests","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_summary":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_tokens":[":","return",":","\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570","\u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl","\u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self",".","parse"],"function":"def start_requests(self):\n \"\"\"\n :return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse\n \"\"\"\n yield Request(url='http:\/\/www.aii.com',\n meta={\"list_offset\":self.list_offset} ,\n callback=self.parse, dont_filter=True)","function_tokens":["def","start_requests","(","self",")",":","yield","Request","(","url","=","'http:\/\/www.aii.com'",",","meta","=","{","\"list_offset\"",":","self",".","list_offset","}",",","callback","=","self",".","parse",",","dont_filter","=","True",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article_list.py#L35-L42"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article_list.py","language":"python","identifier":"ArticleListSpider.parse","parameters":"(self, response)","argument_list":"","return_statement":"","docstring":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","response",":",":","return",":","\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570"],"function":"def parse(self, response):\n \"\"\"\n :param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n self.counter += 1\n cmc = response.get_ext_data['can_msg_continue']\n next_offset = response.get_ext_data['next_offset']\n item = LoadMoreItem()\n item['article_list'] = response.get_ext_data['data']\n item['nickname'] = response.get_ext_data['nickname']\n self.current_nickname = response.get_ext_data['nickname']\n gc.report_crawling({'nickname':item['nickname'],\n 'percent':'UNK',\n 'more':cmc,\n 'title':len(item['article_list'])})\n yield item\n if cmc == 1:\n yield Request(url='http:\/\/www.aii.com',\n meta={\"list_offset\":next_offset} ,\n callback=self.parse, dont_filter=True)","function_tokens":["def","parse","(","self",",","response",")",":","self",".","counter","+=","1","cmc","=","response",".","get_ext_data","[","'can_msg_continue'","]","next_offset","=","response",".","get_ext_data","[","'next_offset'","]","item","=","LoadMoreItem","(",")","item","[","'article_list'","]","=","response",".","get_ext_data","[","'data'","]","item","[","'nickname'","]","=","response",".","get_ext_data","[","'nickname'","]","self",".","current_nickname","=","response",".","get_ext_data","[","'nickname'","]","gc",".","report_crawling","(","{","'nickname'",":","item","[","'nickname'","]",",","'percent'",":","'UNK'",",","'more'",":","cmc",",","'title'",":","len","(","item","[","'article_list'","]",")","}",")","yield","item","if","cmc","==","1",":","yield","Request","(","url","=","'http:\/\/www.aii.com'",",","meta","=","{","\"list_offset\"",":","next_offset","}",",","callback","=","self",".","parse",",","dont_filter","=","True",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article_list.py#L44-L64"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article_list.py","language":"python","identifier":"ArticleListSpider.close","parameters":"(self, reason)","argument_list":"","return_statement":"","docstring":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","reason",":",":","return",":","\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570"],"function":"def close(self, reason):\n \"\"\"\n :param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n # \u5220\u9664\u88ab\u5220\u9664\u7684\u516c\u4f17\u53f7 \u88ab\u5220\u9664\u7684\u516c\u4f17\u53f7content_url\u4e3a\u7a7a\n from db import delete\n delete(self.current_nickname, content_url=\"\")\n print(self.name,\"\u722c\u866b\u5173\u95ed\")","function_tokens":["def","close","(","self",",","reason",")",":","# \u5220\u9664\u88ab\u5220\u9664\u7684\u516c\u4f17\u53f7 \u88ab\u5220\u9664\u7684\u516c\u4f17\u53f7content_url\u4e3a\u7a7a","from","db","import","delete","delete","(","self",".","current_nickname",",","content_url","=","\"\"",")","print","(","self",".","name",",","\"\u722c\u866b\u5173\u95ed\")",""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article_list.py#L66-L74"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleSpider.__init__","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"","docstring":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_summary":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_tokens":[":","param","args",":",":","param","kwargs",":","\u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570"],"function":"def __init__(self, *args, **kwargs):\n \"\"\"\n :param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570\n \"\"\"\n # \u5305\u542b\u5f53\u524d\u516c\u4f17\u53f7\u6240\u6709\u4e0d\u5b58\u5728\u6587\u672c\u5185\u5bb9\u6570\u636e\u7684\u751f\u6210\u5668\n self.current_nickname = TidyReqData.get_nickname()\n self.articles_list = get_collection_article(self.current_nickname,article={\"$exists\": False},title={\"$exists\": True})\n self.crawler_begin_time = time()\n self.crawler_parse_counter = 0","function_tokens":["def","__init__","(","self",",","*","args",",","*","*","kwargs",")",":","# \u5305\u542b\u5f53\u524d\u516c\u4f17\u53f7\u6240\u6709\u4e0d\u5b58\u5728\u6587\u672c\u5185\u5bb9\u6570\u636e\u7684\u751f\u6210\u5668","self",".","current_nickname","=","TidyReqData",".","get_nickname","(",")","self",".","articles_list","=","get_collection_article","(","self",".","current_nickname",",","article","=","{","\"$exists\"",":","False","}",",","title","=","{","\"$exists\"",":","True","}",")","self",".","crawler_begin_time","=","time","(",")","self",".","crawler_parse_counter","=","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L32-L42"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleSpider.start_requests","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_summary":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_tokens":[":","return",":","\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570","\u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl","\u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self",".","parse"],"function":"def start_requests(self):\n \"\"\"\n :return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse\n \"\"\"\n for article in self.articles_list:\n if \"weixin\" in article['content_url']:\n yield Request(url=article['content_url'],callback=self.parse)","function_tokens":["def","start_requests","(","self",")",":","for","article","in","self",".","articles_list",":","if","\"weixin\"","in","article","[","'content_url'","]",":","yield","Request","(","url","=","article","[","'content_url'","]",",","callback","=","self",".","parse",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L44-L51"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleSpider.parse","parameters":"(self, response)","argument_list":"","return_statement":"","docstring":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","response",":",":","return",":","\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570"],"function":"def parse(self, response):\n \"\"\"\n :param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n item = CrawlArticleItem()\n item['article_data'] = response.get_ext_data['article_data']\n item['nickname'] = response.get_ext_data['nickname']\n item['raw_url'] = response.get_ext_data['raw_url']\n self.crawler_parse_counter += 1\n time_gap = time()-self.crawler_begin_time\n print(round(time_gap\/self.crawler_parse_counter,3),item['article_data']['article'].replace('\\n',''))\n # \u53d1\u9001\u72b6\u6001\u7ed9\u524d\u7aef\n crawling_item = {}\n crawling_item['nickname'] = item['nickname']\n crawling_item['percent'] = self.crawler_parse_counter\n crawling_item['more'] = round(time_gap\/self.crawler_parse_counter,3)\n crawling_item['title'] = find_one(item['nickname'],item['raw_url'])['title'][:10]\n gc.report_crawling(crawling_item)\n yield item","function_tokens":["def","parse","(","self",",","response",")",":","item","=","CrawlArticleItem","(",")","item","[","'article_data'","]","=","response",".","get_ext_data","[","'article_data'","]","item","[","'nickname'","]","=","response",".","get_ext_data","[","'nickname'","]","item","[","'raw_url'","]","=","response",".","get_ext_data","[","'raw_url'","]","self",".","crawler_parse_counter","+=","1","time_gap","=","time","(",")","-","self",".","crawler_begin_time","print","(","round","(","time_gap","\/","self",".","crawler_parse_counter",",","3",")",",","item","[","'article_data'","]","[","'article'","]",".","replace","(","'\\n'",",","''",")",")","# \u53d1\u9001\u72b6\u6001\u7ed9\u524d\u7aef","crawling_item","=","{","}","crawling_item","[","'nickname'","]","=","item","[","'nickname'","]","crawling_item","[","'percent'","]","=","self",".","crawler_parse_counter","crawling_item","[","'more'","]","=","round","(","time_gap","\/","self",".","crawler_parse_counter",",","3",")","crawling_item","[","'title'","]","=","find_one","(","item","[","'nickname'","]",",","item","[","'raw_url'","]",")","[","'title'","]","[",":","10","]","gc",".","report_crawling","(","crawling_item",")","yield","item"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L53-L72"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleSpider.close","parameters":"(self, reason)","argument_list":"","return_statement":"","docstring":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","reason",":",":","return",":","\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570"],"function":"def close(self, reason):\n \"\"\"\n :param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n time_gap = time()-self.crawler_begin_time\n if self.crawler_parse_counter != 0:\n print(\"%s\u722c\u866b\u5173\u95ed \u7528\u65f6%d \u5171\u8ba1\u722c\u53d6%d \u5e73\u5747%f\"%(self.name, time_gap, self.crawler_parse_counter, time_gap\/self.crawler_parse_counter))\n from instance.global_instance import gs\n print(\"\u6b63\u5728\u4e3a %s \u521b\u5efa\u7d22\u5f15...\"%(self.current_nickname))\n index_result = gs.index_db_docs(self.current_nickname)\n print(\"\u7d22\u5f15\u5b8c\u6210\",index_result)\n from db.meta_data import insert_article_metadata\n insert_article_metadata(self.current_nickname,{'date':datetime.datetime.now(),'articles_num':self.crawler_parse_counter})","function_tokens":["def","close","(","self",",","reason",")",":","time_gap","=","time","(",")","-","self",".","crawler_begin_time","if","self",".","crawler_parse_counter","!=","0",":","print","(","\"%s\u722c\u866b\u5173\u95ed \u7528\u65f6%d \u5171\u8ba1\u722c\u53d6%d \u5e73\u5747%f\"%(self.name, time_gap, s","e","l","f.cr","a","wler","_","arse_cou","n","er, ","t","ime_gap\/self.crawler_","p","rse_coun","t","er))","","","","","from","instance",".","global_instance","import","gs","print","(","\"\u6b63\u5728\u4e3a %s \u521b\u5efa\u7d22\u5f15...\"%(self.current","_","n","ickn","a","me))","","","index_result","=","gs",".","index_db_docs","(","self",".","current_nickname",")","print","(","\"\u7d22\u5f15\u5b8c\u6210\",index_r","e","sult)","","from","db",".","meta_data","import","insert_article_metadata","insert_article_metadata","(","self",".","current_nickname",",","{","'date'",":","datetime",".","datetime",".","now","(",")",",","'articles_num'",":","self",".","crawler_parse_counter","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L74-L87"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleReadDataSpider.__init__","parameters":"(self, *args, **kwargs)","argument_list":"","return_statement":"","docstring":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_summary":":param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570","docstring_tokens":[":","param","args",":",":","param","kwargs",":","\u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570"],"function":"def __init__(self, *args, **kwargs):\n \"\"\"\n :param args:\n :param kwargs:\n \u5b9e\u4f8b\u5316\u722c\u866b\u9700\u8981\u8c03\u7528\u7684\u51fd\u6570\n \"\"\"\n # \u5305\u542b\u5f53\u524d\u516c\u4f17\u53f7\u6240\u6709\u4e0d\u5b58\u5728\u6587\u672c\u5185\u5bb9\u6570\u636e\u7684\u751f\u6210\u5668\n self.current_nickname = TidyReqData.get_nickname()\n print(self.current_nickname)\n articles_list = get_collection_article(self.current_nickname,read_num={\"$exists\": False},comment_id={\"$exists\": True})\n self.articles_list = []\n for article in articles_list:\n self.articles_list.append(article)\n self.task_num = len(self.articles_list)\n self.task_counter = 0\n self.begin_time = time()\n self.pre_time = time()","function_tokens":["def","__init__","(","self",",","*","args",",","*","*","kwargs",")",":","# \u5305\u542b\u5f53\u524d\u516c\u4f17\u53f7\u6240\u6709\u4e0d\u5b58\u5728\u6587\u672c\u5185\u5bb9\u6570\u636e\u7684\u751f\u6210\u5668","self",".","current_nickname","=","TidyReqData",".","get_nickname","(",")","print","(","self",".","current_nickname",")","articles_list","=","get_collection_article","(","self",".","current_nickname",",","read_num","=","{","\"$exists\"",":","False","}",",","comment_id","=","{","\"$exists\"",":","True","}",")","self",".","articles_list","=","[","]","for","article","in","articles_list",":","self",".","articles_list",".","append","(","article",")","self",".","task_num","=","len","(","self",".","articles_list",")","self",".","task_counter","=","0","self",".","begin_time","=","time","(",")","self",".","pre_time","=","time","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L109-L125"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleReadDataSpider.start_requests","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_summary":":return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse","docstring_tokens":[":","return",":","\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570","\u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl","\u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self",".","parse"],"function":"def start_requests(self):\n \"\"\"\n :return:\u91cd\u65b0\u722c\u866b\u7684\u5165\u53e3\u51fd\u6570, \u5426\u8005\u76f4\u63a5\u8bf7\u6c42start_urls\u4e2d\u7684\u5404\u4e2aurl\n \u91cd\u5199\u4e4b\u540e\u624b\u52a8\u8c03\u7528Request\u5e76\u6307\u5b9a\u56de\u8c03\u51fd\u6570\u4f8b\u5982self.parse\n \"\"\"\n for article in self.articles_list:\n if ':' in article['content_url']:\n request = Request(url=article['content_url'],callback=self.parse, dont_filter=False)\n request.set_ext_data({'content_url':article['content_url'],\n 'comment_id':article['comment_id']})\n yield request","function_tokens":["def","start_requests","(","self",")",":","for","article","in","self",".","articles_list",":","if","':'","in","article","[","'content_url'","]",":","request","=","Request","(","url","=","article","[","'content_url'","]",",","callback","=","self",".","parse",",","dont_filter","=","False",")","request",".","set_ext_data","(","{","'content_url'",":","article","[","'content_url'","]",",","'comment_id'",":","article","[","'comment_id'","]","}",")","yield","request"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L127-L137"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleReadDataSpider.parse","parameters":"(self, response)","argument_list":"","return_statement":"","docstring":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","response",":",":","return",":","\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570"],"function":"def parse(self, response):\n \"\"\"\n :param response:\n :return:\u8bf7\u6c42\u5b8c\u6210\u4e4b\u540e\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n item = CrawlArticleReadDataItem()\n item['read_data'] = response.get_ext_data['read_data']\n item['nickname'] = response.get_ext_data['nickname']\n item['content_url'] = response.get_ext_data['content_url']\n # \u6253\u5370\u72b6\u722c\u866b\u72b6\u6001\u4fe1\u606f\n self.task_counter += 1\n pre_time_gap = time()-self.pre_time\n total_time_gap = time()-self.begin_time\n time_need = (self.task_num-self.task_counter)*(total_time_gap\/self.task_counter)\n print(round(pre_time_gap,2),\n round(total_time_gap\/self.task_counter,2),\n \"%d\/%d\"%(self.task_counter,self.task_num),\n response.get_ext_data['read_data']['read_num'],\n response.get_ext_data['read_data']['like_num'],\n response.get_ext_data['read_data']['nick_name'],\n str(datetime.timedelta(seconds=time_need)).split('.')[0]\n )\n self.pre_time = time()\n crawling_item = {}\n crawling_item['nickname'] = item['nickname']\n crawling_item['percent'] = '%d\/%d'%(self.task_counter,self.task_num)\n crawling_item['more'] = response.get_ext_data['read_data']['read_num']\n crawling_item['title'] = find_one(item['nickname'],item['content_url'])['title'][:10]\n gc.report_crawling(crawling_item)\n yield item","function_tokens":["def","parse","(","self",",","response",")",":","item","=","CrawlArticleReadDataItem","(",")","item","[","'read_data'","]","=","response",".","get_ext_data","[","'read_data'","]","item","[","'nickname'","]","=","response",".","get_ext_data","[","'nickname'","]","item","[","'content_url'","]","=","response",".","get_ext_data","[","'content_url'","]","# \u6253\u5370\u72b6\u722c\u866b\u72b6\u6001\u4fe1\u606f","self",".","task_counter","+=","1","pre_time_gap","=","time","(",")","-","self",".","pre_time","total_time_gap","=","time","(",")","-","self",".","begin_time","time_need","=","(","self",".","task_num","-","self",".","task_counter",")","*","(","total_time_gap","\/","self",".","task_counter",")","print","(","round","(","pre_time_gap",",","2",")",",","round","(","total_time_gap","\/","self",".","task_counter",",","2",")",",","\"%d\/%d\"","%","(","self",".","task_counter",",","self",".","task_num",")",",","response",".","get_ext_data","[","'read_data'","]","[","'read_num'","]",",","response",".","get_ext_data","[","'read_data'","]","[","'like_num'","]",",","response",".","get_ext_data","[","'read_data'","]","[","'nick_name'","]",",","str","(","datetime",".","timedelta","(","seconds","=","time_need",")",")",".","split","(","'.'",")","[","0","]",")","self",".","pre_time","=","time","(",")","crawling_item","=","{","}","crawling_item","[","'nickname'","]","=","item","[","'nickname'","]","crawling_item","[","'percent'","]","=","'%d\/%d'","%","(","self",".","task_counter",",","self",".","task_num",")","crawling_item","[","'more'","]","=","response",".","get_ext_data","[","'read_data'","]","[","'read_num'","]","crawling_item","[","'title'","]","=","find_one","(","item","[","'nickname'","]",",","item","[","'content_url'","]",")","[","'title'","]","[",":","10","]","gc",".","report_crawling","(","crawling_item",")","yield","item"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L139-L168"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler\/crawler\/spiders\/article.py","language":"python","identifier":"ArticleReadDataSpider.close","parameters":"(self, reason)","argument_list":"","return_statement":"","docstring":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_summary":":param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570","docstring_tokens":[":","param","reason",":",":","return",":","\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570"],"function":"def close(self, reason):\n \"\"\"\n :param reason:\n :return:\u6240\u6709url\u8bf7\u6c42\u5b8c\u6bd5\u4e4b\u540e\u5173\u95ed\u722c\u866b\u7684\u56de\u8c03\u51fd\u6570\n \"\"\"\n print(self.name,\"\u722c\u866b\u5173\u95ed\")","function_tokens":["def","close","(","self",",","reason",")",":","print","(","self",".","name",",","\"\u722c\u866b\u5173\u95ed\")",""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler\/crawler\/spiders\/article.py#L170-L175"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch._index_name","parameters":"(self, nickname)","argument_list":"","return_statement":"return self.index_prefix+'_'+(to_pinyin_full(nickname)).lower()","docstring":":param nickname:\n :return: \u6839\u636e\u516c\u4f17\u53f7nickname\u7684\u62fc\u97f3\u4ea7\u751f\u4e13\u7528\u7684index\u540d\u79f0\uff08\u6682\u65f6\u6ca1\u6709\u6dfb\u62fc\u97f3\u76f8\u540c\u7684\u5904\u7406\u903b\u8f91\uff09, \u5148\u8f6c\u5316\u4e3a\u62fc\u97f3\u5f62\u5f0f\u518d\u589e\u52a0\u524d\u7f00","docstring_summary":":param nickname:\n :return: \u6839\u636e\u516c\u4f17\u53f7nickname\u7684\u62fc\u97f3\u4ea7\u751f\u4e13\u7528\u7684index\u540d\u79f0\uff08\u6682\u65f6\u6ca1\u6709\u6dfb\u62fc\u97f3\u76f8\u540c\u7684\u5904\u7406\u903b\u8f91\uff09, \u5148\u8f6c\u5316\u4e3a\u62fc\u97f3\u5f62\u5f0f\u518d\u589e\u52a0\u524d\u7f00","docstring_tokens":[":","param","nickname",":",":","return",":","\u6839\u636e\u516c\u4f17\u53f7nickname\u7684\u62fc\u97f3\u4ea7\u751f\u4e13\u7528\u7684index\u540d\u79f0\uff08\u6682\u65f6\u6ca1\u6709\u6dfb\u62fc\u97f3\u76f8\u540c\u7684\u5904\u7406\u903b\u8f91\uff09","\u5148\u8f6c\u5316\u4e3a\u62fc\u97f3\u5f62\u5f0f\u518d\u589e\u52a0\u524d\u7f00"],"function":"def _index_name(self, nickname):\n \"\"\"\n :param nickname:\n :return: \u6839\u636e\u516c\u4f17\u53f7nickname\u7684\u62fc\u97f3\u4ea7\u751f\u4e13\u7528\u7684index\u540d\u79f0\uff08\u6682\u65f6\u6ca1\u6709\u6dfb\u62fc\u97f3\u76f8\u540c\u7684\u5904\u7406\u903b\u8f91\uff09, \u5148\u8f6c\u5316\u4e3a\u62fc\u97f3\u5f62\u5f0f\u518d\u589e\u52a0\u524d\u7f00\n \"\"\"\n return self.index_prefix+'_'+(to_pinyin_full(nickname)).lower()","function_tokens":["def","_index_name","(","self",",","nickname",")",":","return","self",".","index_prefix","+","'_'","+","(","to_pinyin_full","(","nickname",")",")",".","lower","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L21-L26"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.get_all_indices","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u83b7\u53d6es\u4e2d\u516c\u4f17\u53f7\u76f8\u5173\u7684\u6240\u6709index","docstring_summary":":return:\u83b7\u53d6es\u4e2d\u516c\u4f17\u53f7\u76f8\u5173\u7684\u6240\u6709index","docstring_tokens":[":","return",":","\u83b7\u53d6es\u4e2d\u516c\u4f17\u53f7\u76f8\u5173\u7684\u6240\u6709index"],"function":"def get_all_indices(self):\n \"\"\"\n :return:\u83b7\u53d6es\u4e2d\u516c\u4f17\u53f7\u76f8\u5173\u7684\u6240\u6709index\n \"\"\"\n pass","function_tokens":["def","get_all_indices","(","self",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L28-L32"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.create_index","parameters":"(self,nickname)","argument_list":"","return_statement":"return index_name","docstring":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3\n :return:\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u521b\u5efaindex \u6bd4\u5982\u8bbe\u7f6e\u5b57\u6bb5\u683c\u5f0f\u548c\u6307\u5b9a\u641c\u7d22\u5206\u8bcd\u5668\n \u5728index\u6587\u6863\u4e4b\u524d\u5e94\u8be5\u5148mapping index \u4e3b\u8981\u662f\u8fdb\u884c\u6587\u672c\u5206\u8bcd\u5b57\u6bb5\u8bbe\u7f6e","docstring_summary":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3\n :return:\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u521b\u5efaindex \u6bd4\u5982\u8bbe\u7f6e\u5b57\u6bb5\u683c\u5f0f\u548c\u6307\u5b9a\u641c\u7d22\u5206\u8bcd\u5668\n \u5728index\u6587\u6863\u4e4b\u524d\u5e94\u8be5\u5148mapping index \u4e3b\u8981\u662f\u8fdb\u884c\u6587\u672c\u5206\u8bcd\u5b57\u6bb5\u8bbe\u7f6e","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3",":","return",":","\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u521b\u5efaindex","\u6bd4\u5982\u8bbe\u7f6e\u5b57\u6bb5\u683c\u5f0f\u548c\u6307\u5b9a\u641c\u7d22\u5206\u8bcd\u5668","\u5728index\u6587\u6863\u4e4b\u524d\u5e94\u8be5\u5148mapping","index","\u4e3b\u8981\u662f\u8fdb\u884c\u6587\u672c\u5206\u8bcd\u5b57\u6bb5\u8bbe\u7f6e"],"function":"def create_index(self,nickname):\n \"\"\"\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3\n :return:\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u521b\u5efaindex \u6bd4\u5982\u8bbe\u7f6e\u5b57\u6bb5\u683c\u5f0f\u548c\u6307\u5b9a\u641c\u7d22\u5206\u8bcd\u5668\n \u5728index\u6587\u6863\u4e4b\u524d\u5e94\u8be5\u5148mapping index \u4e3b\u8981\u662f\u8fdb\u884c\u6587\u672c\u5206\u8bcd\u5b57\u6bb5\u8bbe\u7f6e\n \"\"\"\n mapping_body = {}\n mapping_body['properties'] = doc_schema\n index_name = self._index_name(nickname)\n exists = es.indices.exists(index_name)\n if exists is False:\n es.indices.create(index_name)\n es.indices.put_mapping(index=self._index_name(nickname), doc_type=self.doc_type, body=mapping_body)\n logger.info('\u521b\u5efaindex %s \u6210\u529f'%(nickname))\n else:\n logger.info('index %s \u5df2\u7ecf\u5b58\u5728'%(nickname))\n return index_name","function_tokens":["def","create_index","(","self",",","nickname",")",":","mapping_body","=","{","}","mapping_body","[","'properties'","]","=","doc_schema","index_name","=","self",".","_index_name","(","nickname",")","exists","=","es",".","indices",".","exists","(","index_name",")","if","exists","is","False",":","es",".","indices",".","create","(","index_name",")","es",".","indices",".","put_mapping","(","index","=","self",".","_index_name","(","nickname",")",",","doc_type","=","self",".","doc_type",",","body","=","mapping_body",")","logger",".","info","(","'\u521b\u5efaindex %s \u6210\u529f'%(nickna","m","e","))","","","else",":","logger",".","info","(","'index %s \u5df2\u7ecf\u5b58\u5728'%(nickna","m","e","))","","","return","index_name"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L34-L50"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.delete_index","parameters":"(self, nickname)","argument_list":"","return_statement":"","docstring":":param nickname: \u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3 *\u5220\u9664\u6240\u6709index\n :return:\u5220\u9664index\u548c\u8be5index\u4e0b\u7684\u6240\u6709doc","docstring_summary":":param nickname: \u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3 *\u5220\u9664\u6240\u6709index\n :return:\u5220\u9664index\u548c\u8be5index\u4e0b\u7684\u6240\u6709doc","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3","*","\u5220\u9664\u6240\u6709index",":","return",":","\u5220\u9664index\u548c\u8be5index\u4e0b\u7684\u6240\u6709doc"],"function":"def delete_index(self, nickname):\n \"\"\"\n :param nickname: \u516c\u4f17\u53f7\u6635\u79f0\u7684\u62fc\u97f3 *\u5220\u9664\u6240\u6709index\n :return:\u5220\u9664index\u548c\u8be5index\u4e0b\u7684\u6240\u6709doc\n \"\"\"\n if nickname is not \"*\":\n index_name = self._index_name(nickname)\n es.indices.delete(index_name)","function_tokens":["def","delete_index","(","self",",","nickname",")",":","if","nickname","is","not","\"*\"",":","index_name","=","self",".","_index_name","(","nickname",")","es",".","indices",".","delete","(","index_name",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L52-L59"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.index_db_docs","parameters":"(self, nickname)","argument_list":"","return_statement":"return result","docstring":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return: \u4ecemongodb\u4e2d\u83b7\u53d6\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6570\u636e \u4f7f\u7528bulk\u64cd\u4f5cindex\u8fdb\u5165es","docstring_summary":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return: \u4ecemongodb\u4e2d\u83b7\u53d6\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6570\u636e \u4f7f\u7528bulk\u64cd\u4f5cindex\u8fdb\u5165es","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","return",":","\u4ecemongodb\u4e2d\u83b7\u53d6\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6570\u636e","\u4f7f\u7528bulk\u64cd\u4f5cindex\u8fdb\u5165es"],"function":"def index_db_docs(self, nickname):\n \"\"\"\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return: \u4ecemongodb\u4e2d\u83b7\u53d6\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6570\u636e \u4f7f\u7528bulk\u64cd\u4f5cindex\u8fdb\u5165es\n \"\"\"\n # \u5148\u521b\u5efaindex\n index_name = self.create_index(nickname)\n # \u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u8be5\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0\n articles = get_collection_article(nickname,article={\"$exists\": True},title={\"$exists\": True})\n articles_cache = []\n # mongodb\u7684\u8fde\u63a510\u5206\u949f\u4e4b\u540e\u4f1a\u8fc7\u671f \u671f\u95f4\u53ef\u80fd\u4f1a\u51fa\u73b0\u5b8c\u4e0d\u6210index\u7684\u60c5\u51b5 \u6545\u5148\u5c06\u516c\u4f17\u53f7\u7684\u5168\u90e8\u5386\u53f2\u6587\u7ae0\u7f13\u5b58\n for article in articles:\n doc = dict((key, article[key]) for key in doc_schema)\n articles_cache.append(doc)\n # \u4f7f\u7528bulk\u64cd\u4f5cindex\u6587\u6863\n result = self.index_bulk(index_name,articles_cache)\n return result","function_tokens":["def","index_db_docs","(","self",",","nickname",")",":","# \u5148\u521b\u5efaindex","index_name","=","self",".","create_index","(","nickname",")","# \u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u8be5\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0","articles","=","get_collection_article","(","nickname",",","article","=","{","\"$exists\"",":","True","}",",","title","=","{","\"$exists\"",":","True","}",")","articles_cache","=","[","]","# mongodb\u7684\u8fde\u63a510\u5206\u949f\u4e4b\u540e\u4f1a\u8fc7\u671f \u671f\u95f4\u53ef\u80fd\u4f1a\u51fa\u73b0\u5b8c\u4e0d\u6210index\u7684\u60c5\u51b5 \u6545\u5148\u5c06\u516c\u4f17\u53f7\u7684\u5168\u90e8\u5386\u53f2\u6587\u7ae0\u7f13\u5b58","for","article","in","articles",":","doc","=","dict","(","(","key",",","article","[","key","]",")","for","key","in","doc_schema",")","articles_cache",".","append","(","doc",")","# \u4f7f\u7528bulk\u64cd\u4f5cindex\u6587\u6863","result","=","self",".","index_bulk","(","index_name",",","articles_cache",")","return","result"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L61-L77"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.index_docs","parameters":"(self, index_name, doc_dicts)","argument_list":"","return_statement":"","docstring":":param index_name:\n :param doc_dicts:\n :return:","docstring_summary":":param index_name:\n :param doc_dicts:\n :return:","docstring_tokens":[":","param","index_name",":",":","param","doc_dicts",":",":","return",":"],"function":"def index_docs(self, index_name, doc_dicts):\n \"\"\"\n :param index_name:\n :param doc_dicts:\n :return:\n \"\"\"\n for doc_dict in doc_dicts:\n self.index_doc(index_name, doc_dict)","function_tokens":["def","index_docs","(","self",",","index_name",",","doc_dicts",")",":","for","doc_dict","in","doc_dicts",":","self",".","index_doc","(","index_name",",","doc_dict",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L79-L86"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.doc_exist","parameters":"(self, index_name, doc_dict)","argument_list":"","return_statement":"return result","docstring":":param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict: \u6587\u6863\u4f53\n :return:\u6587\u6863\u5b58\u5728\u8fd4\u56de1 \u6587\u6863\u4e0d\u5b58\u5728\u8fd4\u56de0","docstring_summary":":param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict: \u6587\u6863\u4f53\n :return:\u6587\u6863\u5b58\u5728\u8fd4\u56de1 \u6587\u6863\u4e0d\u5b58\u5728\u8fd4\u56de0","docstring_tokens":[":","param","index_name",":","es\u4e2d\u7684index\u540d\u79f0",":","param","doc_dict",":","\u6587\u6863\u4f53",":","return",":","\u6587\u6863\u5b58\u5728\u8fd4\u56de1","\u6587\u6863\u4e0d\u5b58\u5728\u8fd4\u56de0"],"function":"def doc_exist(self, index_name, doc_dict):\n \"\"\"\n :param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict: \u6587\u6863\u4f53\n :return:\u6587\u6863\u5b58\u5728\u8fd4\u56de1 \u6587\u6863\u4e0d\u5b58\u5728\u8fd4\u56de0\n \"\"\"\n # \u4f7f\u7528\u6587\u7ae0\u7684\u8fde\u63a5\u5224\u65ad\u6587\u6863\u5b58\u5728\u4e0e\u5426 \u5b58\u5728\u6570\u91cf\u4e3a1 \u4e0d\u5b58\u5728\u6570\u91cf\u4e3a0\n try:\n body = {\n \"query\":{\"match_phrase\":{'content_url':doc_dict['content_url']}},\n }\n result = es.count(index=index_name, doc_type=self.doc_type, body=body)['count']\n # \u5982\u679c\u516c\u4f17\u53f7\u5bf9\u5e94\u7684index\u4e0d\u5b58\u5728\u5219\u53d1\u751f\u9519\u8bef \u4e5f\u5c31\u8bf4\u660e\u8be5\u6587\u7ae0\u5e76\u672a\u88ab\u521b\u5efa\u7d22\u5f15\n except :\n result = 0\n return result","function_tokens":["def","doc_exist","(","self",",","index_name",",","doc_dict",")",":","# \u4f7f\u7528\u6587\u7ae0\u7684\u8fde\u63a5\u5224\u65ad\u6587\u6863\u5b58\u5728\u4e0e\u5426 \u5b58\u5728\u6570\u91cf\u4e3a1 \u4e0d\u5b58\u5728\u6570\u91cf\u4e3a0","try",":","body","=","{","\"query\"",":","{","\"match_phrase\"",":","{","'content_url'",":","doc_dict","[","'content_url'","]","}","}",",","}","result","=","es",".","count","(","index","=","index_name",",","doc_type","=","self",".","doc_type",",","body","=","body",")","[","'count'","]","# \u5982\u679c\u516c\u4f17\u53f7\u5bf9\u5e94\u7684index\u4e0d\u5b58\u5728\u5219\u53d1\u751f\u9519\u8bef \u4e5f\u5c31\u8bf4\u660e\u8be5\u6587\u7ae0\u5e76\u672a\u88ab\u521b\u5efa\u7d22\u5f15","except",":","result","=","0","return","result"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L88-L103"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.index_doc","parameters":"(self, index_name, doc_dict)","argument_list":"","return_statement":"","docstring":":param index_name:es\u4e2d\u7684index\u540d\u79f0\n :param doc_body:\u6587\u6863\u4f53\n :return:\u65b0\u5efa\u6216\u8005\u66f4\u65b0doc","docstring_summary":":param index_name:es\u4e2d\u7684index\u540d\u79f0\n :param doc_body:\u6587\u6863\u4f53\n :return:\u65b0\u5efa\u6216\u8005\u66f4\u65b0doc","docstring_tokens":[":","param","index_name",":","es\u4e2d\u7684index\u540d\u79f0",":","param","doc_body",":","\u6587\u6863\u4f53",":","return",":","\u65b0\u5efa\u6216\u8005\u66f4\u65b0doc"],"function":"def index_doc(self, index_name, doc_dict):\n \"\"\"\n :param index_name:es\u4e2d\u7684index\u540d\u79f0\n :param doc_body:\u6587\u6863\u4f53\n :return:\u65b0\u5efa\u6216\u8005\u66f4\u65b0doc\n \"\"\"\n doc = dict((key, doc_dict[key]) for key in doc_schema)\n # \u5f53\u516c\u4f17\u53f7\u6587\u7ae0\u66f4\u65b0\u4e4b\u540e\u8fd8\u4ea7\u751f\u65b0\u7684\u6587\u7ae0 \u76f4\u63a5\u8df3\u8fc7\u5bf9\u65e7\u6709\u6587\u7ae0\u7684index\n if self.doc_exist(index_name, doc_dict) == 1:\n return\n try:\n es.index(index=index_name, doc_type=self.doc_type, id=doc['content_url'], body=doc)\n logger.info('Index %d %s %s'%(doc['article_id'], index_name, doc['title']))\n print('Index %d %s %s'%(doc['article_id'], index_name, doc['title']))\n except:\n logger.warning('index \u6587\u6863\u5931\u8d25:%s %s'%(doc['nickname'], doc['title']))","function_tokens":["def","index_doc","(","self",",","index_name",",","doc_dict",")",":","doc","=","dict","(","(","key",",","doc_dict","[","key","]",")","for","key","in","doc_schema",")","# \u5f53\u516c\u4f17\u53f7\u6587\u7ae0\u66f4\u65b0\u4e4b\u540e\u8fd8\u4ea7\u751f\u65b0\u7684\u6587\u7ae0 \u76f4\u63a5\u8df3\u8fc7\u5bf9\u65e7\u6709\u6587\u7ae0\u7684index","if","self",".","doc_exist","(","index_name",",","doc_dict",")","==","1",":","return","try",":","es",".","index","(","index","=","index_name",",","doc_type","=","self",".","doc_type",",","id","=","doc","[","'content_url'","]",",","body","=","doc",")","logger",".","info","(","'Index %d %s %s'","%","(","doc","[","'article_id'","]",",","index_name",",","doc","[","'title'","]",")",")","print","(","'Index %d %s %s'","%","(","doc","[","'article_id'","]",",","index_name",",","doc","[","'title'","]",")",")","except",":","logger",".","warning","(","'index \u6587\u6863\u5931\u8d25:%s %s'%(doc['n","i","c","kna","m","e'], doc['","t","i","le'","]","))","","",""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L105-L120"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.index_bulk","parameters":"(self, index_name, doc_dict_list)","argument_list":"","return_statement":"return result","docstring":":param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict_list: \u6587\u6863list doc\u5305\u542b\u4e86\u9700\u8981\u5728es\u4e2d\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u5373\u53ef \u4e5f\u53ef\u5305\u542b\u66f4\u591a\u5b57\u6bb5\u4f46\u4f1a\u8fc7\u6ee4\u6389\n :return:\u4f7f\u7528bulk\u8fdb\u884c\u6279\u91cfindex API\u4f1a\u6839\u636e\u6307\u5b9a\u7684_id\u5b57\u6bb5\u53bb\u91cd \u800c\u4e14\u652f\u6301\u66f4\u65b0","docstring_summary":":param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict_list: \u6587\u6863list doc\u5305\u542b\u4e86\u9700\u8981\u5728es\u4e2d\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u5373\u53ef \u4e5f\u53ef\u5305\u542b\u66f4\u591a\u5b57\u6bb5\u4f46\u4f1a\u8fc7\u6ee4\u6389\n :return:\u4f7f\u7528bulk\u8fdb\u884c\u6279\u91cfindex API\u4f1a\u6839\u636e\u6307\u5b9a\u7684_id\u5b57\u6bb5\u53bb\u91cd \u800c\u4e14\u652f\u6301\u66f4\u65b0","docstring_tokens":[":","param","index_name",":","es\u4e2d\u7684index\u540d\u79f0",":","param","doc_dict_list",":","\u6587\u6863list","doc\u5305\u542b\u4e86\u9700\u8981\u5728es\u4e2d\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u5373\u53ef","\u4e5f\u53ef\u5305\u542b\u66f4\u591a\u5b57\u6bb5\u4f46\u4f1a\u8fc7\u6ee4\u6389",":","return",":","\u4f7f\u7528bulk\u8fdb\u884c\u6279\u91cfindex","API\u4f1a\u6839\u636e\u6307\u5b9a\u7684_id\u5b57\u6bb5\u53bb\u91cd","\u800c\u4e14\u652f\u6301\u66f4\u65b0"],"function":"def index_bulk(self, index_name, doc_dict_list):\n \"\"\"\n :param index_name: es\u4e2d\u7684index\u540d\u79f0\n :param doc_dict_list: \u6587\u6863list doc\u5305\u542b\u4e86\u9700\u8981\u5728es\u4e2d\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u5373\u53ef \u4e5f\u53ef\u5305\u542b\u66f4\u591a\u5b57\u6bb5\u4f46\u4f1a\u8fc7\u6ee4\u6389\n :return:\u4f7f\u7528bulk\u8fdb\u884c\u6279\u91cfindex API\u4f1a\u6839\u636e\u6307\u5b9a\u7684_id\u5b57\u6bb5\u53bb\u91cd \u800c\u4e14\u652f\u6301\u66f4\u65b0\n \"\"\"\n if self.index_prefix not in index_name:\n index_name = self._index_name(index_name)\n actions = []\n for doc_dict in doc_dict_list:\n action = {\n \"_index\": index_name,\n \"_type\": self.doc_type,\n \"_id\": doc_dict['content_url'],\n \"_source\": doc_dict\n }\n actions.append(action)\n result = helpers.bulk(es, actions)\n return result","function_tokens":["def","index_bulk","(","self",",","index_name",",","doc_dict_list",")",":","if","self",".","index_prefix","not","in","index_name",":","index_name","=","self",".","_index_name","(","index_name",")","actions","=","[","]","for","doc_dict","in","doc_dict_list",":","action","=","{","\"_index\"",":","index_name",",","\"_type\"",":","self",".","doc_type",",","\"_id\"",":","doc_dict","[","'content_url'","]",",","\"_source\"",":","doc_dict","}","actions",".","append","(","action",")","result","=","helpers",".","bulk","(","es",",","actions",")","return","result"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L122-L140"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.delete_doc","parameters":"(self, nickname, url)","argument_list":"","return_statement":"","docstring":":param nickname:\n :param url:\n :return: \u6839\u636eURL\u5220\u9664","docstring_summary":":param nickname:\n :param url:\n :return: \u6839\u636eURL\u5220\u9664","docstring_tokens":[":","param","nickname",":",":","param","url",":",":","return",":","\u6839\u636eURL\u5220\u9664"],"function":"def delete_doc(self, nickname, url):\n \"\"\"\n :param nickname:\n :param url:\n :return: \u6839\u636eURL\u5220\u9664\n \"\"\"\n index_name = self._index_name(nickname)\n es.delete(index=index_name, doc_type=self.doc_type,id=url)","function_tokens":["def","delete_doc","(","self",",","nickname",",","url",")",":","index_name","=","self",".","_index_name","(","nickname",")","es",".","delete","(","index","=","index_name",",","doc_type","=","self",".","doc_type",",","id","=","url",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L142-L149"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.search","parameters":"(self, nicknames, search_data, from_size={\"from\":0,\"size\":10}, source=None)","argument_list":"","return_statement":"","docstring":":param nicknames:\u516c\u4f17\u53f7\u6635\u79f0\u5217\u8868\n :param search_data:\u641c\u7d22\u5b57\u7b26\u4e32\n :param source:\u8fd4\u56de\u6570\u636e\u9700\u8981\u5305\u542b\u7684\u5b57\u6bb5\n :return:\u641c\u7d22","docstring_summary":":param nicknames:\u516c\u4f17\u53f7\u6635\u79f0\u5217\u8868\n :param search_data:\u641c\u7d22\u5b57\u7b26\u4e32\n :param source:\u8fd4\u56de\u6570\u636e\u9700\u8981\u5305\u542b\u7684\u5b57\u6bb5\n :return:\u641c\u7d22","docstring_tokens":[":","param","nicknames",":","\u516c\u4f17\u53f7\u6635\u79f0\u5217\u8868",":","param","search_data",":","\u641c\u7d22\u5b57\u7b26\u4e32",":","param","source",":","\u8fd4\u56de\u6570\u636e\u9700\u8981\u5305\u542b\u7684\u5b57\u6bb5",":","return",":","\u641c\u7d22"],"function":"def search(self, nicknames, search_data, from_size={\"from\":0,\"size\":10}, source=None):\n \"\"\"\n :param nicknames:\u516c\u4f17\u53f7\u6635\u79f0\u5217\u8868\n :param search_data:\u641c\u7d22\u5b57\u7b26\u4e32\n :param source:\u8fd4\u56de\u6570\u636e\u9700\u8981\u5305\u542b\u7684\u5b57\u6bb5\n :return:\u641c\u7d22\n \"\"\"\n # \u6839\u636e\u516c\u4f17\u53f7\u7684\u6635\u79f0\n indices = []\n st = deepcopy(search_template)\n dls = self.search_data_preprocess(search_data)\n st.update(dls)\n if source != None:\n st[\"_source\"] = source\n # \u66f4\u65b0from \u548c size \u652f\u6301\u5206\u9875\n try:\n st[\"from\"] = from_size[\"from\"]\n st[\"size\"] = from_size[\"size\"]\n except:\n logger.warning(\"from_size\u5b57\u6bb5\u9519\u8bef %s\"%(str(from_size)))\n if nicknames == []:\n indices = 'gzh*'\n else:\n for nickname in nicknames:\n indices.append(self._index_name(nickname))\n\n try:\n result = es.search(index=indices, doc_type=self.doc_type, body=st)['hits']\n return result\n except Exception as e:\n logger.critical(\"\u641c\u7d22\u9519\u8bef \u53ef\u80fd\u662f\u6709\u90e8\u5206\u516c\u4f17\u53f7\u6ca1\u6709\u5efa\u7acb\u7d22\u5f15%s\"%(str(indices)))\n return \"ERROR\"","function_tokens":["def","search","(","self",",","nicknames",",","search_data",",","from_size","=","{","\"from\"",":","0",",","\"size\"",":","10","}",",","source","=","None",")",":","# \u6839\u636e\u516c\u4f17\u53f7\u7684\u6635\u79f0","indices","=","[","]","st","=","deepcopy","(","search_template",")","dls","=","self",".","search_data_preprocess","(","search_data",")","st",".","update","(","dls",")","if","source","!=","None",":","st","[","\"_source\"","]","=","source","# \u66f4\u65b0from \u548c size \u652f\u6301\u5206\u9875","try",":","st","[","\"from\"","]","=","from_size","[","\"from\"","]","st","[","\"size\"","]","=","from_size","[","\"size\"","]","except",":","logger",".","warning","(","\"from_size\u5b57\u6bb5\u9519\u8bef %s\"%(str(fr","o","m","_si","z","e)))","","","","if","nicknames","==","[","]",":","indices","=","'gzh*'","else",":","for","nickname","in","nicknames",":","indices",".","append","(","self",".","_index_name","(","nickname",")",")","try",":","result","=","es",".","search","(","index","=","indices",",","doc_type","=","self",".","doc_type",",","body","=","st",")","[","'hits'","]","return","result","except","Exception","as","e",":","logger",".","critical","(","\"\u641c\u7d22\u9519\u8bef \u53ef\u80fd\u662f\u6709\u90e8\u5206\u516c\u4f17\u53f7\u6ca1\u6709\u5efa\u7acb\u7d22\u5f15%s\"%(str(indices)))","","","","","","","","","return","\"ERROR\""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L161-L192"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.search_get_all","parameters":"(self,nicknames,search_data,source)","argument_list":"","return_statement":"return result_data","docstring":":param nicknames:\n :param search_data:\n :param fields:\n :return: \u8fd4\u56de\u641c\u7d22\u7ed3\u679c\u4e2d\u7684\u5168\u90e8\u8bb0\u5f55\u4e2d\u7684\u81ea\u5b9a\u5b57\u6bb5","docstring_summary":":param nicknames:\n :param search_data:\n :param fields:\n :return: \u8fd4\u56de\u641c\u7d22\u7ed3\u679c\u4e2d\u7684\u5168\u90e8\u8bb0\u5f55\u4e2d\u7684\u81ea\u5b9a\u5b57\u6bb5","docstring_tokens":[":","param","nicknames",":",":","param","search_data",":",":","param","fields",":",":","return",":","\u8fd4\u56de\u641c\u7d22\u7ed3\u679c\u4e2d\u7684\u5168\u90e8\u8bb0\u5f55\u4e2d\u7684\u81ea\u5b9a\u5b57\u6bb5"],"function":"def search_get_all(self,nicknames,search_data,source):\n \"\"\"\n :param nicknames:\n :param search_data:\n :param fields:\n :return: \u8fd4\u56de\u641c\u7d22\u7ed3\u679c\u4e2d\u7684\u5168\u90e8\u8bb0\u5f55\u4e2d\u7684\u81ea\u5b9a\u5b57\u6bb5\n \"\"\"\n total = self.search(nicknames=nicknames, search_data=search_data,from_size={\"from\":0,\"size\":1},source=source)[\"total\"]\n # \u9650\u5236\u83b7\u53d6\u7684\u6570\u636e\u91cf\n if total>=10000:\n total = 10000\n result_data = []\n hits = self.search(\n nicknames=nicknames,\n search_data=search_data,\n from_size={\"from\":0,\"size\":total},\n source=source)['hits']\n for hit in hits:\n result_data.append(hit['_source'])\n return result_data","function_tokens":["def","search_get_all","(","self",",","nicknames",",","search_data",",","source",")",":","total","=","self",".","search","(","nicknames","=","nicknames",",","search_data","=","search_data",",","from_size","=","{","\"from\"",":","0",",","\"size\"",":","1","}",",","source","=","source",")","[","\"total\"","]","# \u9650\u5236\u83b7\u53d6\u7684\u6570\u636e\u91cf","if","total",">=","10000",":","total","=","10000","result_data","=","[","]","hits","=","self",".","search","(","nicknames","=","nicknames",",","search_data","=","search_data",",","from_size","=","{","\"from\"",":","0",",","\"size\"",":","total","}",",","source","=","source",")","[","'hits'","]","for","hit","in","hits",":","result_data",".","append","(","hit","[","'_source'","]",")","return","result_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L194-L213"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/__init__.py","language":"python","identifier":"GZHSearch.search_data_preprocess","parameters":"(self, search_data)","argument_list":"","return_statement":"return {\"query\":query_value,\"sort\":sort_value}","docstring":":param search_data:\n :return: \u5bf9\u5373\u5c06\u641c\u7d22\u7684\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406 \u89e3\u6790\u641c\u7d22\u6a21\u5f0f\n \u6570\u636e\u4e2d\u5305\u542b\u6a21\u5f0f\uff1a\n \u53cc\u5f15\u53f7\u5305\u542b\u7684\u5185\u5bb9\u4f7f\u7528match_phrase\u5168\u5339\u914d,\u53cc\u5f15\u53f7\u4e4b\u5916\u7684\u5185\u5bb9\u4f7f\u7528\u5206\u8bcd\u6a21\u5f0fmatch\n \u6392\u5e8f\u6a21\u5f0f \u6307\u5b9a\u6392\u5e8f\u5b57\u6bb5\u4ee5\u53ca\u5347\u964d\u65b9\u5f0f\n \u4e3e\u4f8b\uff1a\"\u5fc5\u987b\u5305\u542b\u8bcd\"\u5206\u8bcd\u6a21\u5f0f-time-1\n \u6839\u636e\u641c\u7d22\u6570\u636e\u4e2d\u6307\u5b9a\u7684\u89c4\u5219\u8fd4\u56de\u67e5\u8be2\u7684query\u3001sort\u7b49\u5b57\u6bb5\u6570\u636e","docstring_summary":":param search_data:\n :return: \u5bf9\u5373\u5c06\u641c\u7d22\u7684\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406 \u89e3\u6790\u641c\u7d22\u6a21\u5f0f\n \u6570\u636e\u4e2d\u5305\u542b\u6a21\u5f0f\uff1a\n \u53cc\u5f15\u53f7\u5305\u542b\u7684\u5185\u5bb9\u4f7f\u7528match_phrase\u5168\u5339\u914d,\u53cc\u5f15\u53f7\u4e4b\u5916\u7684\u5185\u5bb9\u4f7f\u7528\u5206\u8bcd\u6a21\u5f0fmatch\n \u6392\u5e8f\u6a21\u5f0f \u6307\u5b9a\u6392\u5e8f\u5b57\u6bb5\u4ee5\u53ca\u5347\u964d\u65b9\u5f0f\n \u4e3e\u4f8b\uff1a\"\u5fc5\u987b\u5305\u542b\u8bcd\"\u5206\u8bcd\u6a21\u5f0f-time-1\n \u6839\u636e\u641c\u7d22\u6570\u636e\u4e2d\u6307\u5b9a\u7684\u89c4\u5219\u8fd4\u56de\u67e5\u8be2\u7684query\u3001sort\u7b49\u5b57\u6bb5\u6570\u636e","docstring_tokens":[":","param","search_data",":",":","return",":","\u5bf9\u5373\u5c06\u641c\u7d22\u7684\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406","\u89e3\u6790\u641c\u7d22\u6a21\u5f0f","\u6570\u636e\u4e2d\u5305\u542b\u6a21\u5f0f\uff1a","\u53cc\u5f15\u53f7\u5305\u542b\u7684\u5185\u5bb9\u4f7f\u7528match_phrase\u5168\u5339\u914d","\u53cc\u5f15\u53f7\u4e4b\u5916\u7684\u5185\u5bb9\u4f7f\u7528\u5206\u8bcd\u6a21\u5f0fmatch","\u6392\u5e8f\u6a21\u5f0f","\u6307\u5b9a\u6392\u5e8f\u5b57\u6bb5\u4ee5\u53ca\u5347\u964d\u65b9\u5f0f","\u4e3e\u4f8b\uff1a","\u5fc5\u987b\u5305\u542b\u8bcd","\u5206\u8bcd\u6a21\u5f0f","-","time","-","1","\u6839\u636e\u641c\u7d22\u6570\u636e\u4e2d\u6307\u5b9a\u7684\u89c4\u5219\u8fd4\u56de\u67e5\u8be2\u7684query\u3001sort\u7b49\u5b57\u6bb5\u6570\u636e"],"function":"def search_data_preprocess(self, search_data):\n \"\"\"\n :param search_data:\n :return: \u5bf9\u5373\u5c06\u641c\u7d22\u7684\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406 \u89e3\u6790\u641c\u7d22\u6a21\u5f0f\n \u6570\u636e\u4e2d\u5305\u542b\u6a21\u5f0f\uff1a\n \u53cc\u5f15\u53f7\u5305\u542b\u7684\u5185\u5bb9\u4f7f\u7528match_phrase\u5168\u5339\u914d,\u53cc\u5f15\u53f7\u4e4b\u5916\u7684\u5185\u5bb9\u4f7f\u7528\u5206\u8bcd\u6a21\u5f0fmatch\n \u6392\u5e8f\u6a21\u5f0f \u6307\u5b9a\u6392\u5e8f\u5b57\u6bb5\u4ee5\u53ca\u5347\u964d\u65b9\u5f0f\n \u4e3e\u4f8b\uff1a\"\u5fc5\u987b\u5305\u542b\u8bcd\"\u5206\u8bcd\u6a21\u5f0f-time-1\n \u6839\u636e\u641c\u7d22\u6570\u636e\u4e2d\u6307\u5b9a\u7684\u89c4\u5219\u8fd4\u56de\u67e5\u8be2\u7684query\u3001sort\u7b49\u5b57\u6bb5\u6570\u636e\n \"\"\"\n sort_mapping = {\n \"gzh\":\"nickname\", #\u516c\u4f17\u53f7\u6635\u79f0\n \"loc\":\"mov\", #\u6587\u7ae0\u53d1\u5e03\u4f4d\u7f6e\n \"author\":\"author\", #\u4f5c\u8005\n \"time\":\"p_date\", #\u53d1\u6587\u65f6\u95f4\n \"read\":\"read_num\", #\u9605\u8bfb\u91cf\n \"like\":\"like\", #\u70b9\u8d5e\u91cf\n \"comm\":\"comments\", #\u8bc4\u8bba\u91cf\n \"reward\":\"reward_num\", #\u8d5e\u8d4f\u91cf\n \"length\":\"article_token_len\",#\u6587\u7ae0\u8bcd\u6570\n \"unk\":\"_score\", #\u672a\u77e5 \u5c31\u6309\u7167\u9ed8\u8ba4\u7684\u5206\u6570\u6392\u5e8f\n }\n sort_dir_mapping = {\n '0':\"asc\",\n '1':\"desc\",\n }\n # \u5206\u79bb\u641c\u7d22\u6570\u636e \u6392\u5e8f\u5b57\u6bb5\u548c\u6392\u5e8f\u987a\u5e8f\n if len(re.findall('-',search_data))==2:\n part_data = search_data.split('-')\n try:\n sort_dir = sort_dir_mapping[part_data[-1]]\n sort_field = sort_mapping[part_data[-2]]\n except:\n sort_dir = sort_dir_mapping['1']\n sort_field = sort_mapping['unk']\n else:\n sort_dir = sort_dir_mapping['1']\n sort_field = sort_mapping['unk']\n search_data = search_data.split('-')[0]\n # \u627e\u51fa\u5fc5\u987b\u5b8c\u6574\u5305\u542b\u7684\u5b57\u6bb5\n data_match_phrase = [x.replace('\"','') for x in re.findall(r'\"\\S*?\"', search_data)]\n data_match = search_data.replace('\"','')\n # \u521b\u5efa\u5fc5\u987b\u5b8c\u6574\u5305\u542b\u5b57\u6bb5\u7684Elsticsearch\u641c\u7d22\u63cf\u8ff0\u6570\u636e\n for x in data_match_phrase:\n data_match = data_match.replace(x,'').replace(' ','')\n query_value = {\n \"bool\": {\n \"must\": []\n }\n }\n match_phrase_item = {\n \"match_phrase\": {\"article\": \"\"}\n }\n match_item = {\n \"match\": {\"article\": \"\"}\n }\n # \u521b\u5efa\u5206\u8bcd\u5b57\u6bb5 \u82f1\u6587\u4e0d\u5206\u8bcd\u6839\u636e\u7a7a\u683c\n if data_match != '':\n match_item[\"match\"][\"article\"] = data_match\n query_value[\"bool\"][\"must\"].append(deepcopy(match_item))\n for item in data_match_phrase:\n match_phrase_item[\"match_phrase\"][\"article\"]=item\n query_value[\"bool\"][\"must\"].append(deepcopy(match_phrase_item))\n\n sort_value = [\n {\n sort_field: {\n \"order\": sort_dir\n }\n }\n ]\n return {\"query\":query_value,\"sort\":sort_value}","function_tokens":["def","search_data_preprocess","(","self",",","search_data",")",":","sort_mapping","=","{","\"gzh\"",":","\"nickname\"",",","#\u516c\u4f17\u53f7\u6635\u79f0","\"loc\"",":","\"mov\"",",","#\u6587\u7ae0\u53d1\u5e03\u4f4d\u7f6e","\"author\"",":","\"author\"",",","#\u4f5c\u8005","\"time\"",":","\"p_date\"",",","#\u53d1\u6587\u65f6\u95f4","\"read\"",":","\"read_num\"",",","#\u9605\u8bfb\u91cf","\"like\"",":","\"like\"",",","#\u70b9\u8d5e\u91cf","\"comm\"",":","\"comments\"",",","#\u8bc4\u8bba\u91cf","\"reward\"",":","\"reward_num\"",",","#\u8d5e\u8d4f\u91cf","\"length\"",":","\"article_token_len\"",",","#\u6587\u7ae0\u8bcd\u6570","\"unk\"",":","\"_score\"",",","#\u672a\u77e5 \u5c31\u6309\u7167\u9ed8\u8ba4\u7684\u5206\u6570\u6392\u5e8f","}","sort_dir_mapping","=","{","'0'",":","\"asc\"",",","'1'",":","\"desc\"",",","}","# \u5206\u79bb\u641c\u7d22\u6570\u636e \u6392\u5e8f\u5b57\u6bb5\u548c\u6392\u5e8f\u987a\u5e8f","if","len","(","re",".","findall","(","'-'",",","search_data",")",")","==","2",":","part_data","=","search_data",".","split","(","'-'",")","try",":","sort_dir","=","sort_dir_mapping","[","part_data","[","-","1","]","]","sort_field","=","sort_mapping","[","part_data","[","-","2","]","]","except",":","sort_dir","=","sort_dir_mapping","[","'1'","]","sort_field","=","sort_mapping","[","'unk'","]","else",":","sort_dir","=","sort_dir_mapping","[","'1'","]","sort_field","=","sort_mapping","[","'unk'","]","search_data","=","search_data",".","split","(","'-'",")","[","0","]","# \u627e\u51fa\u5fc5\u987b\u5b8c\u6574\u5305\u542b\u7684\u5b57\u6bb5","data_match_phrase","=","[","x",".","replace","(","'\"'",",","''",")","for","x","in","re",".","findall","(","r'\"\\S*?\"'",",","search_data",")","]","data_match","=","search_data",".","replace","(","'\"'",",","''",")","# \u521b\u5efa\u5fc5\u987b\u5b8c\u6574\u5305\u542b\u5b57\u6bb5\u7684Elsticsearch\u641c\u7d22\u63cf\u8ff0\u6570\u636e","for","x","in","data_match_phrase",":","data_match","=","data_match",".","replace","(","x",",","''",")",".","replace","(","' '",",","''",")","query_value","=","{","\"bool\"",":","{","\"must\"",":","[","]","}","}","match_phrase_item","=","{","\"match_phrase\"",":","{","\"article\"",":","\"\"","}","}","match_item","=","{","\"match\"",":","{","\"article\"",":","\"\"","}","}","# \u521b\u5efa\u5206\u8bcd\u5b57\u6bb5 \u82f1\u6587\u4e0d\u5206\u8bcd\u6839\u636e\u7a7a\u683c","if","data_match","!=","''",":","match_item","[","\"match\"","]","[","\"article\"","]","=","data_match","query_value","[","\"bool\"","]","[","\"must\"","]",".","append","(","deepcopy","(","match_item",")",")","for","item","in","data_match_phrase",":","match_phrase_item","[","\"match_phrase\"","]","[","\"article\"","]","=","item","query_value","[","\"bool\"","]","[","\"must\"","]",".","append","(","deepcopy","(","match_phrase_item",")",")","sort_value","=","[","{","sort_field",":","{","\"order\"",":","sort_dir","}","}","]","return","{","\"query\"",":","query_value",",","\"sort\"",":","sort_value","}"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/__init__.py#L215-L286"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/setting.py","language":"python","identifier":"GZHSearchSetting.get_all_settings","parameters":"(self)","argument_list":"","return_statement":"return setting_data","docstring":":return:\u8fd4\u56de\u6240\u6709\u7684\u8bbe\u7f6e\u53c2\u6570\u5b57\u5178\u5f62\u5f0f, \u4ee5\u5c5e\u6027\u4e4b\u4e00:\u641c\u7d22\u8303\u56f4\u4e3a\u4f8b\n \u5f53\u524d\u9009\u7528\u7684\u8303\u56f4\u7c7b\u578b, \u6bcf\u79cd\u8303\u56f4\u7c7b\u578b\u4e0b\u5df2\u7ecf\u7eb3\u5165\u7684\u5143\u7d20\u548c\u5c1a\u53ef\u7eb3\u5165\u7684\u5143\u7d20\n setting_data = {\n 'search_range':{\n 'current_search_range':'\u516c\u4f17\u53f7 or \u7c7b\u522b',\n 'gzh_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'gzh_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n },\n }","docstring_summary":":return:\u8fd4\u56de\u6240\u6709\u7684\u8bbe\u7f6e\u53c2\u6570\u5b57\u5178\u5f62\u5f0f, \u4ee5\u5c5e\u6027\u4e4b\u4e00:\u641c\u7d22\u8303\u56f4\u4e3a\u4f8b\n \u5f53\u524d\u9009\u7528\u7684\u8303\u56f4\u7c7b\u578b, \u6bcf\u79cd\u8303\u56f4\u7c7b\u578b\u4e0b\u5df2\u7ecf\u7eb3\u5165\u7684\u5143\u7d20\u548c\u5c1a\u53ef\u7eb3\u5165\u7684\u5143\u7d20\n setting_data = {\n 'search_range':{\n 'current_search_range':'\u516c\u4f17\u53f7 or \u7c7b\u522b',\n 'gzh_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'gzh_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n },\n }","docstring_tokens":[":","return",":","\u8fd4\u56de\u6240\u6709\u7684\u8bbe\u7f6e\u53c2\u6570\u5b57\u5178\u5f62\u5f0f","\u4ee5\u5c5e\u6027\u4e4b\u4e00",":","\u641c\u7d22\u8303\u56f4\u4e3a\u4f8b","\u5f53\u524d\u9009\u7528\u7684\u8303\u56f4\u7c7b\u578b","\u6bcf\u79cd\u8303\u56f4\u7c7b\u578b\u4e0b\u5df2\u7ecf\u7eb3\u5165\u7684\u5143\u7d20\u548c\u5c1a\u53ef\u7eb3\u5165\u7684\u5143\u7d20","setting_data","=","{","search_range",":","{","current_search_range",":","\u516c\u4f17\u53f7","or","\u7c7b\u522b","gzh_members",":","[","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","]","gzh_available",":","[","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","]","cat_members",":","[","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","]","cat_available",":","[","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","\u7231\u8fea\u65af","]","}","}"],"function":"def get_all_settings(self):\n \"\"\"\n :return:\u8fd4\u56de\u6240\u6709\u7684\u8bbe\u7f6e\u53c2\u6570\u5b57\u5178\u5f62\u5f0f, \u4ee5\u5c5e\u6027\u4e4b\u4e00:\u641c\u7d22\u8303\u56f4\u4e3a\u4f8b\n \u5f53\u524d\u9009\u7528\u7684\u8303\u56f4\u7c7b\u578b, \u6bcf\u79cd\u8303\u56f4\u7c7b\u578b\u4e0b\u5df2\u7ecf\u7eb3\u5165\u7684\u5143\u7d20\u548c\u5c1a\u53ef\u7eb3\u5165\u7684\u5143\u7d20\n setting_data = {\n 'search_range':{\n 'current_search_range':'\u516c\u4f17\u53f7 or \u7c7b\u522b',\n 'gzh_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'gzh_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_members':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n 'cat_available':['\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af','\u7231\u8fea\u65af'],\n },\n }\n \"\"\"\n setting_data = {}\n setting_data['search_range'] = {}\n # \u83b7\u53d6\u5168\u90e8\u516c\u4f17\u53f7\u5217\u8868\n all_gzh_list = list(get_article_metadata().keys())\n all_gzh_list.append('\u5168\u90e8')\n all_cat_list = []\n # \u83b7\u5f97\u5168\u90e8\u76ee\u5f55\u5217\u8868\n cats = DBQ.get_queue_by_kv(queue_type='\u516c\u4f17\u53f7\u5206\u7c7b')\n for cat in cats:\n all_cat_list.append(cat['name'])\n # \u83b7\u53d6\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u641c\u7d22\u8303\u56f4\u65b9\u5f0f\n try:\n if DBQ('\u516c\u4f17\u53f7',self.queue_type).get_ext_data()['inuse'] is True:\n current_search_range = '\u516c\u4f17\u53f7'\n else:\n current_search_range = '\u7c7b\u522b'\n except Exception as e:\n current_search_range = '\u516c\u4f17\u53f7'\n # \u83b7\u5f97\u73b0\u5b58\u641c\u7d22\u8303\u56f4\u7684\u516c\u4f17\u53f7\u5217\u8868\n queue = DBQ.get_queue_by_kv(queue_type=self.queue_type,name='\u516c\u4f17\u53f7')[0]['queue']\n gzh_members = []\n for element in queue:\n gzh_members.append(element['id'])\n gzh_available = sub_list(all_gzh_list, gzh_members)\n # \u83b7\u5f97\u73b0\u5b58\u8303\u56f4\u7684\u7c7b\u522b\u5217\u8868\n queue = DBQ.get_queue_by_kv(queue_type=self.queue_type,name='\u7c7b\u522b')[0]['queue']\n cat_members = []\n for element in queue:\n cat_members.append(element['id'])\n cat_available = sub_list(all_cat_list, cat_members)\n\n setting_data['search_range']['current_search_range'] = current_search_range\n setting_data['search_range']['gzh_members'] = gzh_members\n setting_data['search_range']['gzh_available'] = gzh_available\n setting_data['search_range']['cat_members'] = cat_members\n setting_data['search_range']['cat_available'] = cat_available\n return setting_data","function_tokens":["def","get_all_settings","(","self",")",":","setting_data","=","{","}","setting_data","[","'search_range'","]","=","{","}","# \u83b7\u53d6\u5168\u90e8\u516c\u4f17\u53f7\u5217\u8868","all_gzh_list","=","list","(","get_article_metadata","(",")",".","keys","(",")",")","all_gzh_list",".","append","(","'\u5168\u90e8')","","all_cat_list","=","[","]","# \u83b7\u5f97\u5168\u90e8\u76ee\u5f55\u5217\u8868","cats","=","DBQ",".","get_queue_by_kv","(","queue_type","=","'\u516c\u4f17\u53f7\u5206\u7c7b')","","for","cat","in","cats",":","all_cat_list",".","append","(","cat","[","'name'","]",")","# \u83b7\u53d6\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u641c\u7d22\u8303\u56f4\u65b9\u5f0f","try",":","if","DBQ","(","'\u516c\u4f17\u53f7',self.","q","ueue","_","type).get_","e","x","t_data()['in","u","s","e","'] is T","r","e:","","","current_search_range","=","'\u516c\u4f17\u53f7'","else",":","current_search_range","=","'\u7c7b\u522b'","except","Exception","as","e",":","current_search_range","=","'\u516c\u4f17\u53f7'","# \u83b7\u5f97\u73b0\u5b58\u641c\u7d22\u8303\u56f4\u7684\u516c\u4f17\u53f7\u5217\u8868","queue","=","DBQ",".","get_queue_by_kv","(","queue_type","=","self",".","queue_type",",","name","=","'\u516c\u4f17\u53f7')[0]['","q","u","e","u","e","']","","gzh_members","=","[","]","for","element","in","queue",":","gzh_members",".","append","(","element","[","'id'","]",")","gzh_available","=","sub_list","(","all_gzh_list",",","gzh_members",")","# \u83b7\u5f97\u73b0\u5b58\u8303\u56f4\u7684\u7c7b\u522b\u5217\u8868","queue","=","DBQ",".","get_queue_by_kv","(","queue_type","=","self",".","queue_type",",","name","=","'\u7c7b\u522b')[0]","[","'","q","u","e","ue']","","cat_members","=","[","]","for","element","in","queue",":","cat_members",".","append","(","element","[","'id'","]",")","cat_available","=","sub_list","(","all_cat_list",",","cat_members",")","setting_data","[","'search_range'","]","[","'current_search_range'","]","=","current_search_range","setting_data","[","'search_range'","]","[","'gzh_members'","]","=","gzh_members","setting_data","[","'search_range'","]","[","'gzh_available'","]","=","gzh_available","setting_data","[","'search_range'","]","[","'cat_members'","]","=","cat_members","setting_data","[","'search_range'","]","[","'cat_available'","]","=","cat_available","return","setting_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/setting.py#L16-L66"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/setting.py","language":"python","identifier":"GZHSearchSetting.change_search_range_type","parameters":"(self, range_type)","argument_list":"","return_statement":"return self.get_all_settings()","docstring":":param range_type:\u8303\u56f4\u7c7b\u578b\n :return:\u66f4\u65b0\u641c\u7d22\u8303\u56f4\u7c7b\u578b","docstring_summary":":param range_type:\u8303\u56f4\u7c7b\u578b\n :return:\u66f4\u65b0\u641c\u7d22\u8303\u56f4\u7c7b\u578b","docstring_tokens":[":","param","range_type",":","\u8303\u56f4\u7c7b\u578b",":","return",":","\u66f4\u65b0\u641c\u7d22\u8303\u56f4\u7c7b\u578b"],"function":"def change_search_range_type(self, range_type):\n \"\"\"\n :param range_type:\u8303\u56f4\u7c7b\u578b\n :return:\u66f4\u65b0\u641c\u7d22\u8303\u56f4\u7c7b\u578b\n \"\"\"\n DBQ('\u7c7b\u522b',self.queue_type).set_ext_data({'inuse':False})\n DBQ('\u516c\u4f17\u53f7',self.queue_type).set_ext_data({'inuse':False})\n if range_type == '\u516c\u4f17\u53f7':\n DBQ('\u516c\u4f17\u53f7',self.queue_type).set_ext_data({'inuse':True})\n elif range_type == '\u7c7b\u522b':\n DBQ('\u7c7b\u522b',self.queue_type).set_ext_data({'inuse':True})\n return self.get_all_settings()","function_tokens":["def","change_search_range_type","(","self",",","range_type",")",":","DBQ","(","'\u7c7b\u522b',sel","f",".que","u","e_type).se","t","_","ext_data({'i","n","u","se':Fal","s","e})","","","DBQ","(","'\u516c\u4f17\u53f7',self.","q","ueue","_","type).set_","e","x","t_data({'inu","s","e","':False","}",")","","","if","range_type","==","'\u516c\u4f17\u53f7':","","DBQ","(","'\u516c\u4f17\u53f7',self.","q","ueue","_","type).set_","e","x","t_data({'inu","s","e","':True}",")","","","","elif","range_type","==","'\u7c7b\u522b':","","DBQ","(","'\u7c7b\u522b',sel","f",".que","u","e_type).se","t","_","ext_data({'i","n","u","se':Tru","e","})","","","return","self",".","get_all_settings","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/setting.py#L68-L79"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/setting.py","language":"python","identifier":"GZHSearchSetting.delete_from_search_range","parameters":"(self, range_type, name)","argument_list":"","return_statement":"return self.get_all_settings()","docstring":":param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u4ece\u6307\u5b9a\u8303\u56f4\u4e2d\u5220\u9664\u5143\u7d20 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type","docstring_summary":":param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u4ece\u6307\u5b9a\u8303\u56f4\u4e2d\u5220\u9664\u5143\u7d20 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type","docstring_tokens":[":","param","range_type",":","\u8303\u56f4\u7c7b\u578b",":","param","name",":","\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0",":","return",":","\u4ece\u6307\u5b9a\u8303\u56f4\u4e2d\u5220\u9664\u5143\u7d20","\u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type"],"function":"def delete_from_search_range(self, range_type, name):\n \"\"\"\n :param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u4ece\u6307\u5b9a\u8303\u56f4\u4e2d\u5220\u9664\u5143\u7d20 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type\n \"\"\"\n if range_type == '\u516c\u4f17\u53f7':\n DBQ('\u516c\u4f17\u53f7',self.queue_type).delete_element({'id':name})\n elif range_type == '\u7c7b\u522b':\n DBQ('\u7c7b\u522b',self.queue_type).delete_element({'id':name})\n self.change_search_range_type(range_type)\n return self.get_all_settings()","function_tokens":["def","delete_from_search_range","(","self",",","range_type",",","name",")",":","if","range_type","==","'\u516c\u4f17\u53f7':","","DBQ","(","'\u516c\u4f17\u53f7',self.","q","ueue","_","type).dele","t","e","_element({'id'",":","n","ame}",")","","","","elif","range_type","==","'\u7c7b\u522b':","","DBQ","(","'\u7c7b\u522b',sel","f",".que","u","e_type).de","l","e","te_element({'i","d","'",":nam","e","})","","","self",".","change_search_range_type","(","range_type",")","return","self",".","get_all_settings","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/setting.py#L81-L92"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/setting.py","language":"python","identifier":"GZHSearchSetting.add_to_search_range","parameters":"(self, range_type, name)","argument_list":"","return_statement":"return self.get_all_settings()","docstring":":param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u6dfb\u52a0\u5143\u7d20\u5230\u6307\u5b9a\u8303\u56f4 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type","docstring_summary":":param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u6dfb\u52a0\u5143\u7d20\u5230\u6307\u5b9a\u8303\u56f4 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type","docstring_tokens":[":","param","range_type",":","\u8303\u56f4\u7c7b\u578b",":","param","name",":","\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0",":","return",":","\u6dfb\u52a0\u5143\u7d20\u5230\u6307\u5b9a\u8303\u56f4","\u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type"],"function":"def add_to_search_range(self, range_type, name):\n \"\"\"\n :param range_type:\u8303\u56f4\u7c7b\u578b\n :param name:\u516c\u4f17\u53f7\u540d\u79f0\u6216\u8005\u7c7b\u522b\u540d\u79f0\n :return: \u6dfb\u52a0\u5143\u7d20\u5230\u6307\u5b9a\u8303\u56f4 \u64cd\u4f5c\u5b8c\u6210\u4e4b\u540e\u66f4\u65b0range_type\n \"\"\"\n if range_type == '\u516c\u4f17\u53f7':\n gzh_queue = DBQ('\u516c\u4f17\u53f7',self.queue_type)\n # \u5982\u679c\u5168\u90e8\u5728\u641c\u7d22\u8303\u56f4\u4e2d\u76f4\u63a5\u8fd4\u56de\n # if '\u5168\u90e8' in self.get_all_settings()['search_range']['gzh_members']:return\n # \u5982\u679c\u5728\u5168\u90e8\u7684\u516c\u4f17\u53f7\u4e2d\u641c\u7d22 \u5219\u961f\u5217\u4e2d\u53ea\u7559\u4e0b'\u5168\u90e8'\n if name == '\u5168\u90e8':\n gzh_queue.delete_all_element()\n gzh_queue.add_element({'id':name})\n elif range_type == '\u7c7b\u522b':\n DBQ('\u7c7b\u522b',self.queue_type).add_element({'id':name})\n self.change_search_range_type(range_type)\n return self.get_all_settings()","function_tokens":["def","add_to_search_range","(","self",",","range_type",",","name",")",":","if","range_type","==","'\u516c\u4f17\u53f7':","","gzh_queue","=","DBQ","(","'\u516c\u4f17\u53f7',self.","q","ueue","_","type)","","# \u5982\u679c\u5168\u90e8\u5728\u641c\u7d22\u8303\u56f4\u4e2d\u76f4\u63a5\u8fd4\u56de","# if '\u5168\u90e8' in self.get_all_settings()['search_range']['gzh_members']:return","# \u5982\u679c\u5728\u5168\u90e8\u7684\u516c\u4f17\u53f7\u4e2d\u641c\u7d22 \u5219\u961f\u5217\u4e2d\u53ea\u7559\u4e0b'\u5168\u90e8'","if","name","==","'\u5168\u90e8':","","gzh_queue",".","delete_all_element","(",")","gzh_queue",".","add_element","(","{","'id'",":","name","}",")","elif","range_type","==","'\u7c7b\u522b':","","DBQ","(","'\u7c7b\u522b',sel","f",".que","u","e_type).ad","d","_","element({'i","d","'",":nam","e","})","","","self",".","change_search_range_type","(","range_type",")","return","self",".","get_all_settings","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/setting.py#L94-L111"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/setting.py","language":"python","identifier":"GZHSearchSetting.search_range_data_preprocess","parameters":"(self,gc)","argument_list":"","return_statement":"","docstring":":parameter gc:GZHCategory\u5b9e\u4f8b\u7528\u4e8e\u83b7\u53d6\u5b58\u5728\u76ee\u5f55\u7684\u516c\u4f17\u53f7\u6210\u5458\u5217\u8868\n :return:\u6839\u636e\u641c\u7d22\u8303\u56f4\u8bbe\u7f6e\u53c2\u6570 \u8f93\u51fa\u516c\u4f17\u53f7\u96c6\u5408\u5217\u8868","docstring_summary":":parameter gc:GZHCategory\u5b9e\u4f8b\u7528\u4e8e\u83b7\u53d6\u5b58\u5728\u76ee\u5f55\u7684\u516c\u4f17\u53f7\u6210\u5458\u5217\u8868\n :return:\u6839\u636e\u641c\u7d22\u8303\u56f4\u8bbe\u7f6e\u53c2\u6570 \u8f93\u51fa\u516c\u4f17\u53f7\u96c6\u5408\u5217\u8868","docstring_tokens":[":","parameter","gc",":","GZHCategory\u5b9e\u4f8b\u7528\u4e8e\u83b7\u53d6\u5b58\u5728\u76ee\u5f55\u7684\u516c\u4f17\u53f7\u6210\u5458\u5217\u8868",":","return",":","\u6839\u636e\u641c\u7d22\u8303\u56f4\u8bbe\u7f6e\u53c2\u6570","\u8f93\u51fa\u516c\u4f17\u53f7\u96c6\u5408\u5217\u8868"],"function":"def search_range_data_preprocess(self,gc):\n \"\"\"\n :parameter gc:GZHCategory\u5b9e\u4f8b\u7528\u4e8e\u83b7\u53d6\u5b58\u5728\u76ee\u5f55\u7684\u516c\u4f17\u53f7\u6210\u5458\u5217\u8868\n :return:\u6839\u636e\u641c\u7d22\u8303\u56f4\u8bbe\u7f6e\u53c2\u6570 \u8f93\u51fa\u516c\u4f17\u53f7\u96c6\u5408\u5217\u8868\n \"\"\"\n # \u6309\u7167\u516c\u4f17\u53f7\n search_range = self.get_all_settings()['search_range']\n if search_range['current_search_range'] == \"\u516c\u4f17\u53f7\":\n if '\u5168\u90e8' in search_range['gzh_members']:\n return []\n return search_range['gzh_members']\n # \u6309\u7167\u5206\u7c7b\n elif search_range['current_search_range'] == \"\u7c7b\u522b\":\n gzhs = []\n search_cats = search_range['cat_members']\n all_cats = gc.get_all_cat_data()\n for member in search_cats:\n for cat in all_cats:\n if member == cat['cat_name']:\n gzhs = gzhs+cat['cat_members']\n break\n return list(set(gzhs))\n # \u5168\u90e8\n else:\n return []","function_tokens":["def","search_range_data_preprocess","(","self",",","gc",")",":","# \u6309\u7167\u516c\u4f17\u53f7","search_range","=","self",".","get_all_settings","(",")","[","'search_range'","]","if","search_range","[","'current_search_range'","]","==","\"\u516c\u4f17\u53f7\":","","if","'\u5168\u90e8' in ","ea","ch_range['gz","h","_members']:","","","return","[","]","return","search_range","[","'gzh_members'","]","# \u6309\u7167\u5206\u7c7b","elif","search_range","[","'current_search_range'","]","==","\"\u7c7b\u522b\":","","gzhs","=","[","]","search_cats","=","search_range","[","'cat_members'","]","all_cats","=","gc",".","get_all_cat_data","(",")","for","member","in","search_cats",":","for","cat","in","all_cats",":","if","member","==","cat","[","'cat_name'","]",":","gzhs","=","gzhs","+","cat","[","'cat_members'","]","break","return","list","(","set","(","gzhs",")",")","# \u5168\u90e8","else",":","return","[","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/setting.py#L113-L137"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/view.py","language":"python","identifier":"search_result_pretty","parameters":"(result)","argument_list":"","return_statement":"return r","docstring":":param result:\n :return:\u683c\u5f0f\u5316es\u641c\u7d22\u51fa\u6765\u7684\u7ed3\u679c\uff0c\u65b9\u4fbfui\u5c55\u793a","docstring_summary":":param result:\n :return:\u683c\u5f0f\u5316es\u641c\u7d22\u51fa\u6765\u7684\u7ed3\u679c\uff0c\u65b9\u4fbfui\u5c55\u793a","docstring_tokens":[":","param","result",":",":","return",":","\u683c\u5f0f\u5316es\u641c\u7d22\u51fa\u6765\u7684\u7ed3\u679c\uff0c\u65b9\u4fbfui\u5c55\u793a"],"function":"def search_result_pretty(result):\n \"\"\"\n :param result:\n :return:\u683c\u5f0f\u5316es\u641c\u7d22\u51fa\u6765\u7684\u7ed3\u679c\uff0c\u65b9\u4fbfui\u5c55\u793a\n \"\"\"\n # from tools.utils import debug_p\n # debug_p(result)\n r = {}\n r['total'] = result['total']\n r['data'] = []\n for article in result['hits']:\n article['_source']['highlight'] = ''.join(article['highlight']['article']).replace('\\n','')\n r['data'].append(article['_source'])\n return r","function_tokens":["def","search_result_pretty","(","result",")",":","# from tools.utils import debug_p","# debug_p(result)","r","=","{","}","r","[","'total'","]","=","result","[","'total'","]","r","[","'data'","]","=","[","]","for","article","in","result","[","'hits'","]",":","article","[","'_source'","]","[","'highlight'","]","=","''",".","join","(","article","[","'highlight'","]","[","'article'","]",")",".","replace","(","'\\n'",",","''",")","r","[","'data'","]",".","append","(","article","[","'_source'","]",")","return","r"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/view.py#L1-L14"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/trend\/__init__.py","language":"python","identifier":"articles_and_time","parameters":"(raw_data, time_gap='month')","argument_list":"","return_statement":"return x_data_list,y_data_list","docstring":":param raw_data:\u6765\u81easearch_get_all\u7684\u8fd4\u56de\u6570\u636e\n :param time_gap:\u65f6\u95f4\u95f4\u9694 \u5929 \u6708 \u5e74\u4e09\u79cd\u5355\u4f4d\n :return:\u8ba1\u7b97\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u5185\u7684\u6587\u7ae0\u6570\u91cf \u5e76\u751f\u6210\u4e8c\u7ef4\u6570\u636e\u7528\u4f5c\u56fe\u8868\u53ef\u89c6\u5316","docstring_summary":":param raw_data:\u6765\u81easearch_get_all\u7684\u8fd4\u56de\u6570\u636e\n :param time_gap:\u65f6\u95f4\u95f4\u9694 \u5929 \u6708 \u5e74\u4e09\u79cd\u5355\u4f4d\n :return:\u8ba1\u7b97\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u5185\u7684\u6587\u7ae0\u6570\u91cf \u5e76\u751f\u6210\u4e8c\u7ef4\u6570\u636e\u7528\u4f5c\u56fe\u8868\u53ef\u89c6\u5316","docstring_tokens":[":","param","raw_data",":","\u6765\u81easearch_get_all\u7684\u8fd4\u56de\u6570\u636e",":","param","time_gap",":","\u65f6\u95f4\u95f4\u9694","\u5929","\u6708","\u5e74\u4e09\u79cd\u5355\u4f4d",":","return",":","\u8ba1\u7b97\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u5185\u7684\u6587\u7ae0\u6570\u91cf","\u5e76\u751f\u6210\u4e8c\u7ef4\u6570\u636e\u7528\u4f5c\u56fe\u8868\u53ef\u89c6\u5316"],"function":"def articles_and_time(raw_data, time_gap='month'):\n \"\"\"\n :param raw_data:\u6765\u81easearch_get_all\u7684\u8fd4\u56de\u6570\u636e\n :param time_gap:\u65f6\u95f4\u95f4\u9694 \u5929 \u6708 \u5e74\u4e09\u79cd\u5355\u4f4d\n :return:\u8ba1\u7b97\u6307\u5b9a\u65f6\u95f4\u95f4\u9694\u5185\u7684\u6587\u7ae0\u6570\u91cf \u5e76\u751f\u6210\u4e8c\u7ef4\u6570\u636e\u7528\u4f5c\u56fe\u8868\u53ef\u89c6\u5316\n \"\"\"\n time_gap_mapping = {\n 'year':['year'],\n 'month':['year','month'],\n 'day':['year','month','day'],\n }\n df = pd.DataFrame(columns=['year', 'month', 'day','week','tag'])\n for i in range(len(raw_data)):\n date_time = datetime.strptime(raw_data[i]['p_date'],'%Y-%m-%dT%H:%M:%S')\n row = p_date_extract(date_time)\n row.append(1)\n df.loc[i] = row\n df = df.groupby(time_gap_mapping[time_gap])[['tag']].describe(percentiles=[.5])\n # df\u5206\u7ec4\u4e4b\u540e\u62bd\u53d6\u51fa\u7eb5\u5750\u6807\u7684\u53c2\u6570\n y_data_list = df['tag']['count'].tolist()\n # df\u5206\u7ec4\u4e4b\u540e\u62bd\u53d6\u51fa\u6a2a\u5750\u6807\u7684\u53c2\u6570\n x_data_list =['-'.join(x) for x in list(df.index.values)]\n return x_data_list,y_data_list","function_tokens":["def","articles_and_time","(","raw_data",",","time_gap","=","'month'",")",":","time_gap_mapping","=","{","'year'",":","[","'year'","]",",","'month'",":","[","'year'",",","'month'","]",",","'day'",":","[","'year'",",","'month'",",","'day'","]",",","}","df","=","pd",".","DataFrame","(","columns","=","[","'year'",",","'month'",",","'day'",",","'week'",",","'tag'","]",")","for","i","in","range","(","len","(","raw_data",")",")",":","date_time","=","datetime",".","strptime","(","raw_data","[","i","]","[","'p_date'","]",",","'%Y-%m-%dT%H:%M:%S'",")","row","=","p_date_extract","(","date_time",")","row",".","append","(","1",")","df",".","loc","[","i","]","=","row","df","=","df",".","groupby","(","time_gap_mapping","[","time_gap","]",")","[","[","'tag'","]","]",".","describe","(","percentiles","=","[",".5","]",")","# df\u5206\u7ec4\u4e4b\u540e\u62bd\u53d6\u51fa\u7eb5\u5750\u6807\u7684\u53c2\u6570","y_data_list","=","df","[","'tag'","]","[","'count'","]",".","tolist","(",")","# df\u5206\u7ec4\u4e4b\u540e\u62bd\u53d6\u51fa\u6a2a\u5750\u6807\u7684\u53c2\u6570","x_data_list","=","[","'-'",".","join","(","x",")","for","x","in","list","(","df",".","index",".","values",")","]","return","x_data_list",",","y_data_list"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/trend\/__init__.py#L7-L29"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/es\/trend\/__init__.py","language":"python","identifier":"p_date_extract","parameters":"(p_date)","argument_list":"","return_statement":"return date","docstring":":param p_date: datetime\u5b9e\u4f8b\n :return:['\u5e74','\u6708','\u65e5','\u661f\u671f']","docstring_summary":":param p_date: datetime\u5b9e\u4f8b\n :return:['\u5e74','\u6708','\u65e5','\u661f\u671f']","docstring_tokens":[":","param","p_date",":","datetime\u5b9e\u4f8b",":","return",":","[","\u5e74","\u6708","\u65e5","\u661f\u671f","]"],"function":"def p_date_extract(p_date):\n \"\"\"\n :param p_date: datetime\u5b9e\u4f8b\n :return:['\u5e74','\u6708','\u65e5','\u661f\u671f']\n \"\"\"\n date = p_date.strftime(\"%Y-%m-%d\").split('-')\n date.append(str(p_date.weekday()+1))\n return date","function_tokens":["def","p_date_extract","(","p_date",")",":","date","=","p_date",".","strftime","(","\"%Y-%m-%d\"",")",".","split","(","'-'",")","date",".","append","(","str","(","p_date",".","weekday","(",")","+","1",")",")","return","date"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/es\/trend\/__init__.py#L37-L44"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/utils.py","language":"python","identifier":"to_pinyin","parameters":"(ch_name)","argument_list":"","return_statement":"return d4","docstring":"\u5c06\u6df7\u5408\u8f6c\u5316\u4e3a\u641c\u7d22\u62fc\u97f3\u5b57\u7b26\n INPUT '\u676d\u5ddefrank1\u6e56\u6ee8\u94f6\u6cf0in77'\n OUTPUT 'hzfrank1hbytin77'","docstring_summary":"\u5c06\u6df7\u5408\u8f6c\u5316\u4e3a\u641c\u7d22\u62fc\u97f3\u5b57\u7b26\n INPUT '\u676d\u5ddefrank1\u6e56\u6ee8\u94f6\u6cf0in77'\n OUTPUT 'hzfrank1hbytin77'","docstring_tokens":["\u5c06\u6df7\u5408\u8f6c\u5316\u4e3a\u641c\u7d22\u62fc\u97f3\u5b57\u7b26","INPUT","\u676d\u5ddefrank1\u6e56\u6ee8\u94f6\u6cf0in77","OUTPUT","hzfrank1hbytin77"],"function":"def to_pinyin(ch_name):\n \"\"\"\n \u5c06\u6df7\u5408\u8f6c\u5316\u4e3a\u641c\u7d22\u62fc\u97f3\u5b57\u7b26\n INPUT '\u676d\u5ddefrank1\u6e56\u6ee8\u94f6\u6cf0in77'\n OUTPUT 'hzfrank1hbytin77'\n \"\"\"\n from pypinyin import lazy_pinyin\n import re\n d1 = re.sub(r'[a-zA-Z0-9]+',' ',ch_name)\n d2 = re.findall(r'[a-zA-Z0-9]+',ch_name)\n d3 = lazy_pinyin(d1)\n d4 = []\n i=0\n for d in d3:\n if d == ' ':\n d4.append(d2[i])\n i+=1\n else:\n d4.append(d[0])\n d4 = ''.join(d4)\n return d4","function_tokens":["def","to_pinyin","(","ch_name",")",":","from","pypinyin","import","lazy_pinyin","import","re","d1","=","re",".","sub","(","r'[a-zA-Z0-9]+'",",","' '",",","ch_name",")","d2","=","re",".","findall","(","r'[a-zA-Z0-9]+'",",","ch_name",")","d3","=","lazy_pinyin","(","d1",")","d4","=","[","]","i","=","0","for","d","in","d3",":","if","d","==","' '",":","d4",".","append","(","d2","[","i","]",")","i","+=","1","else",":","d4",".","append","(","d","[","0","]",")","d4","=","''",".","join","(","d4",")","return","d4"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/utils.py#L2-L22"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/utils.py","language":"python","identifier":"str_to_dict","parameters":"(s, join_symbol=\"\\n\", split_symbol=\":\")","argument_list":"","return_statement":"return data","docstring":"key\u4e0evalue\u901a\u8fc7split_symbol\u8fde\u63a5\uff0c key,value \u5bf9\u4e4b\u95f4\u4f7f\u7528join_symbol\u8fde\u63a5\n \u4f8b\u5982\uff1a a=b&c=d join_symbol\u662f&, split_symbol\u662f=\n :param s: \u539f\u5b57\u7b26\u4e32\n :param join_symbol: \u8fde\u63a5\u7b26\n :param split_symbol: \u5206\u9694\u7b26\n :return: \u5b57\u5178","docstring_summary":"key\u4e0evalue\u901a\u8fc7split_symbol\u8fde\u63a5\uff0c key,value \u5bf9\u4e4b\u95f4\u4f7f\u7528join_symbol\u8fde\u63a5\n \u4f8b\u5982\uff1a a=b&c=d join_symbol\u662f&, split_symbol\u662f=\n :param s: \u539f\u5b57\u7b26\u4e32\n :param join_symbol: \u8fde\u63a5\u7b26\n :param split_symbol: \u5206\u9694\u7b26\n :return: \u5b57\u5178","docstring_tokens":["key\u4e0evalue\u901a\u8fc7split_symbol\u8fde\u63a5\uff0c","key","value","\u5bf9\u4e4b\u95f4\u4f7f\u7528join_symbol\u8fde\u63a5","\u4f8b\u5982\uff1a","a","=","b&c","=","d","join_symbol\u662f&","split_symbol\u662f","=",":","param","s",":","\u539f\u5b57\u7b26\u4e32",":","param","join_symbol",":","\u8fde\u63a5\u7b26",":","param","split_symbol",":","\u5206\u9694\u7b26",":","return",":","\u5b57\u5178"],"function":"def str_to_dict(s, join_symbol=\"\\n\", split_symbol=\":\"):\n \"\"\"\n key\u4e0evalue\u901a\u8fc7split_symbol\u8fde\u63a5\uff0c key,value \u5bf9\u4e4b\u95f4\u4f7f\u7528join_symbol\u8fde\u63a5\n \u4f8b\u5982\uff1a a=b&c=d join_symbol\u662f&, split_symbol\u662f=\n :param s: \u539f\u5b57\u7b26\u4e32\n :param join_symbol: \u8fde\u63a5\u7b26\n :param split_symbol: \u5206\u9694\u7b26\n :return: \u5b57\u5178\n \"\"\"\n s_list = s.split(join_symbol)\n data = dict()\n for item in s_list:\n item = item.strip()\n if item:\n k, v = item.split(split_symbol, 1)\n data[k] = v.strip()\n return data","function_tokens":["def","str_to_dict","(","s",",","join_symbol","=","\"\\n\"",",","split_symbol","=","\":\"",")",":","s_list","=","s",".","split","(","join_symbol",")","data","=","dict","(",")","for","item","in","s_list",":","item","=","item",".","strip","(",")","if","item",":","k",",","v","=","item",".","split","(","split_symbol",",","1",")","data","[","k","]","=","v",".","strip","(",")","return","data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/utils.py#L29-L45"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/utils.py","language":"python","identifier":"sub_list","parameters":"(whole_list, part_list)","argument_list":"","return_statement":"return [x for x in whole_list if x not in part_list]","docstring":":param whole_list:\n :param part_list:\n :return:\u4ecewhole list\u4e2d\u627e\u51fa\u9664\u4e86part_list\u4e4b\u5916\u7684\u5143\u7d20 \u7ec4\u6210\u4e00\u4e2a\u5b50list\u8fd4\u56de","docstring_summary":":param whole_list:\n :param part_list:\n :return:\u4ecewhole list\u4e2d\u627e\u51fa\u9664\u4e86part_list\u4e4b\u5916\u7684\u5143\u7d20 \u7ec4\u6210\u4e00\u4e2a\u5b50list\u8fd4\u56de","docstring_tokens":[":","param","whole_list",":",":","param","part_list",":",":","return",":","\u4ecewhole","list\u4e2d\u627e\u51fa\u9664\u4e86part_list\u4e4b\u5916\u7684\u5143\u7d20","\u7ec4\u6210\u4e00\u4e2a\u5b50list\u8fd4\u56de"],"function":"def sub_list(whole_list, part_list):\n \"\"\"\n :param whole_list:\n :param part_list:\n :return:\u4ecewhole list\u4e2d\u627e\u51fa\u9664\u4e86part_list\u4e4b\u5916\u7684\u5143\u7d20 \u7ec4\u6210\u4e00\u4e2a\u5b50list\u8fd4\u56de\n \"\"\"\n return [x for x in whole_list if x not in part_list]","function_tokens":["def","sub_list","(","whole_list",",","part_list",")",":","return","[","x","for","x","in","whole_list","if","x","not","in","part_list","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/utils.py#L83-L89"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"RQ.__init__","parameters":"(self, q_name)","argument_list":"","return_statement":"","docstring":":param q_name:\u521b\u5efa\u4e00\u4e2a\u961f\u5217 \u5f00\u5934\u5904\u63d2\u5165\u4e00\u4e2a__BEGIN\n \u6240\u6709\u961f\u5217\u540d\u79f0\u5747\u4ee5re__\u5f00\u5934","docstring_summary":":param q_name:\u521b\u5efa\u4e00\u4e2a\u961f\u5217 \u5f00\u5934\u5904\u63d2\u5165\u4e00\u4e2a__BEGIN\n \u6240\u6709\u961f\u5217\u540d\u79f0\u5747\u4ee5re__\u5f00\u5934","docstring_tokens":[":","param","q_name",":","\u521b\u5efa\u4e00\u4e2a\u961f\u5217","\u5f00\u5934\u5904\u63d2\u5165\u4e00\u4e2a__BEGIN","\u6240\u6709\u961f\u5217\u540d\u79f0\u5747\u4ee5re__\u5f00\u5934"],"function":"def __init__(self, q_name):\n \"\"\"\n :param q_name:\u521b\u5efa\u4e00\u4e2a\u961f\u5217 \u5f00\u5934\u5904\u63d2\u5165\u4e00\u4e2a__BEGIN\n \u6240\u6709\u961f\u5217\u540d\u79f0\u5747\u4ee5re__\u5f00\u5934\n \"\"\"\n self.q_name = 'rq__'+q_name\n self.redis = redis_instance","function_tokens":["def","__init__","(","self",",","q_name",")",":","self",".","q_name","=","'rq__'","+","q_name","self",".","redis","=","redis_instance"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L17-L23"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"RQ.push","parameters":"(self, data)","argument_list":"","return_statement":"return 0","docstring":":param data:\n :return:1\u8868\u793a\u63d2\u5165\u6210\u529f 1\u8868\u793a\u5bf9\u8c61\u5df2\u7ecf\u5b58\u5728","docstring_summary":":param data:\n :return:1\u8868\u793a\u63d2\u5165\u6210\u529f 1\u8868\u793a\u5bf9\u8c61\u5df2\u7ecf\u5b58\u5728","docstring_tokens":[":","param","data",":",":","return",":","1\u8868\u793a\u63d2\u5165\u6210\u529f","1\u8868\u793a\u5bf9\u8c61\u5df2\u7ecf\u5b58\u5728"],"function":"def push(self, data):\n \"\"\"\n :param data:\n :return:1\u8868\u793a\u63d2\u5165\u6210\u529f 1\u8868\u793a\u5bf9\u8c61\u5df2\u7ecf\u5b58\u5728\n \"\"\"\n rq = self.get_rq_data()\n if data not in rq:\n self.redis.lpush(self.q_name,data)\n return 1\n return 0","function_tokens":["def","push","(","self",",","data",")",":","rq","=","self",".","get_rq_data","(",")","if","data","not","in","rq",":","self",".","redis",".","lpush","(","self",".","q_name",",","data",")","return","1","return","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L25-L34"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"RQ.pop","parameters":"(self)","argument_list":"","return_statement":"return rq_j_data","docstring":":return:[]\u8868\u793a\u961f\u5217\u5df2\u7ecf\u7a7a\u4e86","docstring_summary":":return:[]\u8868\u793a\u961f\u5217\u5df2\u7ecf\u7a7a\u4e86","docstring_tokens":[":","return",":","[]","\u8868\u793a\u961f\u5217\u5df2\u7ecf\u7a7a\u4e86"],"function":"def pop(self):\n \"\"\"\n :return:[]\u8868\u793a\u961f\u5217\u5df2\u7ecf\u7a7a\u4e86\n \"\"\"\n data = self.redis.rpop(self.q_name)\n try:\n rq_j_data = json.loads(data)\n except:\n if data:\n rq_j_data = data.decode('utf8')\n else:\n rq_j_data = []\n return rq_j_data","function_tokens":["def","pop","(","self",")",":","data","=","self",".","redis",".","rpop","(","self",".","q_name",")","try",":","rq_j_data","=","json",".","loads","(","data",")","except",":","if","data",":","rq_j_data","=","data",".","decode","(","'utf8'",")","else",":","rq_j_data","=","[","]","return","rq_j_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L36-L48"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"RQ.remove","parameters":"(self,data)","argument_list":"","return_statement":"return rq_list","docstring":":param data:\u6839\u636edata\u5220\u9664\u6307\u5b9a\u7684\u5143\u7d20\n :return:\u5220\u9664\u540e\u7684\u961f\u5217","docstring_summary":":param data:\u6839\u636edata\u5220\u9664\u6307\u5b9a\u7684\u5143\u7d20\n :return:\u5220\u9664\u540e\u7684\u961f\u5217","docstring_tokens":[":","param","data",":","\u6839\u636edata\u5220\u9664\u6307\u5b9a\u7684\u5143\u7d20",":","return",":","\u5220\u9664\u540e\u7684\u961f\u5217"],"function":"def remove(self,data):\n \"\"\"\n :param data:\u6839\u636edata\u5220\u9664\u6307\u5b9a\u7684\u5143\u7d20\n :return:\u5220\u9664\u540e\u7684\u961f\u5217\n \"\"\"\n rq_list = self.get_rq_data()\n self.delete_rq()\n for item in reversed(rq_list):\n if item is not data:\n self.push(item)\n rq_list = self.get_rq_data()\n return rq_list","function_tokens":["def","remove","(","self",",","data",")",":","rq_list","=","self",".","get_rq_data","(",")","self",".","delete_rq","(",")","for","item","in","reversed","(","rq_list",")",":","if","item","is","not","data",":","self",".","push","(","item",")","rq_list","=","self",".","get_rq_data","(",")","return","rq_list"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L53-L64"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"RQ.get_rq_data","parameters":"(self)","argument_list":"","return_statement":"return rq_j_data_list","docstring":":return:\u8fd4\u56de\u63d2\u5165\u7684\u6570\u636e","docstring_summary":":return:\u8fd4\u56de\u63d2\u5165\u7684\u6570\u636e","docstring_tokens":[":","return",":","\u8fd4\u56de\u63d2\u5165\u7684\u6570\u636e"],"function":"def get_rq_data(self):\n \"\"\"\n :return:\u8fd4\u56de\u63d2\u5165\u7684\u6570\u636e\n \"\"\"\n rq_b_data_list = self.redis.lrange(self.q_name,0,-1)\n rq_j_data_list = []\n for rq_b_data in rq_b_data_list:\n try:\n rq_j_data = json.loads(rq_b_data)\n except:\n rq_j_data = rq_b_data.decode('utf8')\n rq_j_data_list.append(rq_j_data)\n return rq_j_data_list","function_tokens":["def","get_rq_data","(","self",")",":","rq_b_data_list","=","self",".","redis",".","lrange","(","self",".","q_name",",","0",",","-","1",")","rq_j_data_list","=","[","]","for","rq_b_data","in","rq_b_data_list",":","try",":","rq_j_data","=","json",".","loads","(","rq_b_data",")","except",":","rq_j_data","=","rq_b_data",".","decode","(","'utf8'",")","rq_j_data_list",".","append","(","rq_j_data",")","return","rq_j_data_list"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L66-L78"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.__init__","parameters":"(self, name, queue_type)","argument_list":"","return_statement":"","docstring":":param name:\u961f\u5217\u540d\u79f0\n :param queue_type:\u961f\u5217\u7c7b\u578b \u901a\u5e38\u7528\u4e8e\u6807\u8bc6\u7528\u9014","docstring_summary":":param name:\u961f\u5217\u540d\u79f0\n :param queue_type:\u961f\u5217\u7c7b\u578b \u901a\u5e38\u7528\u4e8e\u6807\u8bc6\u7528\u9014","docstring_tokens":[":","param","name",":","\u961f\u5217\u540d\u79f0",":","param","queue_type",":","\u961f\u5217\u7c7b\u578b","\u901a\u5e38\u7528\u4e8e\u6807\u8bc6\u7528\u9014"],"function":"def __init__(self, name, queue_type):\n \"\"\"\n :param name:\u961f\u5217\u540d\u79f0\n :param queue_type:\u961f\u5217\u7c7b\u578b \u901a\u5e38\u7528\u4e8e\u6807\u8bc6\u7528\u9014\n \"\"\"\n self.name = name\n self.queue_type = queue_type\n self.queue_structure = copy(data_queue_scheme)\n # name, queue_type\u552f\u4e00\u6807\u8bc6\u4e00\u4e2aqueue\n self.queue_structure['name'] = name\n self.queue_structure['queue_type'] = queue_type\n # \u521d\u59cb\u5316\u4e4b\u540e\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u961f\u5217\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n if type(queue_data) is not dict:\n queue_data = copy(self.queue_structure)\n DBQ.col.insert_one(queue_data)","function_tokens":["def","__init__","(","self",",","name",",","queue_type",")",":","self",".","name","=","name","self",".","queue_type","=","queue_type","self",".","queue_structure","=","copy","(","data_queue_scheme",")","# name, queue_type\u552f\u4e00\u6807\u8bc6\u4e00\u4e2aqueue","self",".","queue_structure","[","'name'","]","=","name","self",".","queue_structure","[","'queue_type'","]","=","queue_type","# \u521d\u59cb\u5316\u4e4b\u540e\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u961f\u5217","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","if","type","(","queue_data",")","is","not","dict",":","queue_data","=","copy","(","self",".","queue_structure",")","DBQ",".","col",".","insert_one","(","queue_data",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L106-L121"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.add_element","parameters":"(self, element)","argument_list":"","return_statement":"return queue_data","docstring":":param element:\u5143\u7d20\u6570\u636e elemet\u662f\u4e00\u4e2adict \u5fc5\u987b\u6307\u5b9aid\u5c5e\u6027\n :return:\u589e\u52a0\u4e00\u4e2a\u5143\u7d20","docstring_summary":":param element:\u5143\u7d20\u6570\u636e elemet\u662f\u4e00\u4e2adict \u5fc5\u987b\u6307\u5b9aid\u5c5e\u6027\n :return:\u589e\u52a0\u4e00\u4e2a\u5143\u7d20","docstring_tokens":[":","param","element",":","\u5143\u7d20\u6570\u636e","elemet\u662f\u4e00\u4e2adict","\u5fc5\u987b\u6307\u5b9aid\u5c5e\u6027",":","return",":","\u589e\u52a0\u4e00\u4e2a\u5143\u7d20"],"function":"def add_element(self, element):\n \"\"\"\n :param element:\u5143\u7d20\u6570\u636e elemet\u662f\u4e00\u4e2adict \u5fc5\u987b\u6307\u5b9aid\u5c5e\u6027\n :return:\u589e\u52a0\u4e00\u4e2a\u5143\u7d20\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n # \u66f4\u65b0\n if type(queue_data) is dict:\n self.update_element(element)\n # \u63d2\u5165\n else:\n queue_data = copy(self.queue_structure)\n queue_data['update_time'] = datetime.now()\n queue_data['length'] = 1\n queue_data['queue'] = [element]\n DBQ.col.insert_one(queue_data)\n return queue_data","function_tokens":["def","add_element","(","self",",","element",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","# \u66f4\u65b0","if","type","(","queue_data",")","is","dict",":","self",".","update_element","(","element",")","# \u63d2\u5165","else",":","queue_data","=","copy","(","self",".","queue_structure",")","queue_data","[","'update_time'","]","=","datetime",".","now","(",")","queue_data","[","'length'","]","=","1","queue_data","[","'queue'","]","=","[","element","]","DBQ",".","col",".","insert_one","(","queue_data",")","return","queue_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L123-L139"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.delete_element","parameters":"(self, element)","argument_list":"","return_statement":"return 0","docstring":":param element:\u5143\u7d20\u6570\u636e\n :return: \u6839\u636edata\u4e2d\u7684id\u5220\u9664\u8be5\u5143\u7d20\n 1\u8868\u793a\u4ea7\u51fa\u6210\u529f\n 0\u8868\u793a\u672a\u627e\u5230\u5339\u914did\u7684\u5143\u7d20","docstring_summary":":param element:\u5143\u7d20\u6570\u636e\n :return: \u6839\u636edata\u4e2d\u7684id\u5220\u9664\u8be5\u5143\u7d20\n 1\u8868\u793a\u4ea7\u51fa\u6210\u529f\n 0\u8868\u793a\u672a\u627e\u5230\u5339\u914did\u7684\u5143\u7d20","docstring_tokens":[":","param","element",":","\u5143\u7d20\u6570\u636e",":","return",":","\u6839\u636edata\u4e2d\u7684id\u5220\u9664\u8be5\u5143\u7d20","1\u8868\u793a\u4ea7\u51fa\u6210\u529f","0\u8868\u793a\u672a\u627e\u5230\u5339\u914did\u7684\u5143\u7d20"],"function":"def delete_element(self, element):\n \"\"\"\n :param element:\u5143\u7d20\u6570\u636e\n :return: \u6839\u636edata\u4e2d\u7684id\u5220\u9664\u8be5\u5143\u7d20\n 1\u8868\u793a\u4ea7\u51fa\u6210\u529f\n 0\u8868\u793a\u672a\u627e\u5230\u5339\u914did\u7684\u5143\u7d20\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n\n elements = queue_data['queue']\n for ele in elements:\n if ele['id'] == element['id']:\n elements.remove(ele)\n queue_data['update_time'] = datetime.now()\n queue_data['length'] -= 1\n DBQ.col.update_one({'name':self.name, 'queue_type':self.queue_type},{\"$set\":queue_data})\n return 1\n return 0","function_tokens":["def","delete_element","(","self",",","element",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","elements","=","queue_data","[","'queue'","]","for","ele","in","elements",":","if","ele","[","'id'","]","==","element","[","'id'","]",":","elements",".","remove","(","ele",")","queue_data","[","'update_time'","]","=","datetime",".","now","(",")","queue_data","[","'length'","]","-=","1","DBQ",".","col",".","update_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",",","{","\"$set\"",":","queue_data","}",")","return","1","return","0"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L142-L159"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.update_element","parameters":"(self, element)","argument_list":"","return_statement":"","docstring":":param element: \u5143\u7d20\u6570\u636e\n :return:\u6839\u636edata\u4e2d\u7684id\u66f4\u65b0\u8be5\u5143\u7d20","docstring_summary":":param element: \u5143\u7d20\u6570\u636e\n :return:\u6839\u636edata\u4e2d\u7684id\u66f4\u65b0\u8be5\u5143\u7d20","docstring_tokens":[":","param","element",":","\u5143\u7d20\u6570\u636e",":","return",":","\u6839\u636edata\u4e2d\u7684id\u66f4\u65b0\u8be5\u5143\u7d20"],"function":"def update_element(self, element):\n \"\"\"\n :param element: \u5143\u7d20\u6570\u636e\n :return:\u6839\u636edata\u4e2d\u7684id\u66f4\u65b0\u8be5\u5143\u7d20\n \"\"\"\n # \u5f97\u5230\u961f\u5217 \u5982\u679c\u5b58\u5728\u8fd4\u56dedict\u5426\u5219\u8fd4\u56deNone\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n old_list = queue_data['queue']\n # \u6839\u636eelemet\u66f4\u65b0\u961f\u5217\n result = DBQ.update_dict_list_by_kv(old_list=old_list,element=element)\n queue_data['queue'] = old_list\n queue_data['update_time'] = datetime.now()\n # \u5982\u679c\u662f\u65b0\u589e\u5143\u7d20\u957f\u5ea6\u81ea\u589e1\n if result == 2:\n queue_data['length'] += 1\n DBQ.col.update_one({'name':self.name, 'queue_type':self.queue_type},{\"$set\":queue_data})","function_tokens":["def","update_element","(","self",",","element",")",":","# \u5f97\u5230\u961f\u5217 \u5982\u679c\u5b58\u5728\u8fd4\u56dedict\u5426\u5219\u8fd4\u56deNone","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","old_list","=","queue_data","[","'queue'","]","# \u6839\u636eelemet\u66f4\u65b0\u961f\u5217","result","=","DBQ",".","update_dict_list_by_kv","(","old_list","=","old_list",",","element","=","element",")","queue_data","[","'queue'","]","=","old_list","queue_data","[","'update_time'","]","=","datetime",".","now","(",")","# \u5982\u679c\u662f\u65b0\u589e\u5143\u7d20\u957f\u5ea6\u81ea\u589e1","if","result","==","2",":","queue_data","[","'length'","]","+=","1","DBQ",".","col",".","update_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",",","{","\"$set\"",":","queue_data","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L161-L176"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.delete_all_element","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u6e05\u7a7a\u961f\u5217\u4e2d\u7684\u5143\u7d20","docstring_summary":":return:\u6e05\u7a7a\u961f\u5217\u4e2d\u7684\u5143\u7d20","docstring_tokens":[":","return",":","\u6e05\u7a7a\u961f\u5217\u4e2d\u7684\u5143\u7d20"],"function":"def delete_all_element(self):\n \"\"\"\n :return:\u6e05\u7a7a\u961f\u5217\u4e2d\u7684\u5143\u7d20\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n queue_data['queue'] = []\n DBQ.col.update_one({'name':self.name, 'queue_type':self.queue_type},{\"$set\":queue_data})","function_tokens":["def","delete_all_element","(","self",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","queue_data","[","'queue'","]","=","[","]","DBQ",".","col",".","update_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",",","{","\"$set\"",":","queue_data","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L178-L184"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.delete_self","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u5220\u9664\u961f\u5217\u81ea\u5df1","docstring_summary":":return:\u5220\u9664\u961f\u5217\u81ea\u5df1","docstring_tokens":[":","return",":","\u5220\u9664\u961f\u5217\u81ea\u5df1"],"function":"def delete_self(self):\n \"\"\"\n :return:\u5220\u9664\u961f\u5217\u81ea\u5df1\n \"\"\"\n DBQ.col.delete_one({'name':self.name, 'queue_type':self.queue_type})","function_tokens":["def","delete_self","(","self",")",":","DBQ",".","col",".","delete_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L186-L190"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.get_queue","parameters":"(self)","argument_list":"","return_statement":"return queue_data['queue']","docstring":":return:\u83b7\u5f97queue list\u6570\u636e","docstring_summary":":return:\u83b7\u5f97queue list\u6570\u636e","docstring_tokens":[":","return",":","\u83b7\u5f97queue","list\u6570\u636e"],"function":"def get_queue(self):\n \"\"\"\n :return:\u83b7\u5f97queue list\u6570\u636e\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n return queue_data['queue']","function_tokens":["def","get_queue","(","self",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","return","queue_data","[","'queue'","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L192-L197"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.set_ext_data","parameters":"(self, ext_data)","argument_list":"","return_statement":"","docstring":":param ext_data:\u5b57\u5178\n :return: \u8bbe\u7f6eext_data","docstring_summary":":param ext_data:\u5b57\u5178\n :return: \u8bbe\u7f6eext_data","docstring_tokens":[":","param","ext_data",":","\u5b57\u5178",":","return",":","\u8bbe\u7f6eext_data"],"function":"def set_ext_data(self, ext_data):\n \"\"\"\n :param ext_data:\u5b57\u5178\n :return: \u8bbe\u7f6eext_data\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n queue_data['ext_data'] = ext_data\n DBQ.col.update_one({'name':self.name, 'queue_type':self.queue_type},\n {\"$set\":queue_data})","function_tokens":["def","set_ext_data","(","self",",","ext_data",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","queue_data","[","'ext_data'","]","=","ext_data","DBQ",".","col",".","update_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",",","{","\"$set\"",":","queue_data","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L199-L207"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.get_ext_data","parameters":"(self)","argument_list":"","return_statement":"return None","docstring":":return: \u83b7\u53d6ext_data\u5b57\u5178","docstring_summary":":return: \u83b7\u53d6ext_data\u5b57\u5178","docstring_tokens":[":","return",":","\u83b7\u53d6ext_data\u5b57\u5178"],"function":"def get_ext_data(self):\n \"\"\"\n :return: \u83b7\u53d6ext_data\u5b57\u5178\n \"\"\"\n queue_data = DBQ.col.find_one({'name':self.name, 'queue_type':self.queue_type})\n if type(queue_data) is dict:\n return queue_data['ext_data']\n return None","function_tokens":["def","get_ext_data","(","self",")",":","queue_data","=","DBQ",".","col",".","find_one","(","{","'name'",":","self",".","name",",","'queue_type'",":","self",".","queue_type","}",")","if","type","(","queue_data",")","is","dict",":","return","queue_data","[","'ext_data'","]","return","None"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L209-L216"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.update_dict_list_by_kv","parameters":"(old_list, element, key='id')","argument_list":"","return_statement":"return 2","docstring":":param key:\n :param value:\n :return:\u6839\u636e\u7ed9\u5b9a\u5b57\u5178\u4e2d\u7684\u67d0\u4e2a\u952e\u503c\u5bf9\u8ddf\u65b0\u6240\u5728list, \u4ee5\u4fdd\u8bc1list\u4e2d\u5143\u7d20\u7684\u552f\u4e00\u6027\n \u8fd4\u56de0\u8868\u793a\u5931\u8d25\n \u8fd4\u56de1\u8868\u793a\u66f4\u65b0\n \u8fd4\u56de2\u8868\u793a\u589e\u52a0","docstring_summary":":param key:\n :param value:\n :return:\u6839\u636e\u7ed9\u5b9a\u5b57\u5178\u4e2d\u7684\u67d0\u4e2a\u952e\u503c\u5bf9\u8ddf\u65b0\u6240\u5728list, \u4ee5\u4fdd\u8bc1list\u4e2d\u5143\u7d20\u7684\u552f\u4e00\u6027\n \u8fd4\u56de0\u8868\u793a\u5931\u8d25\n \u8fd4\u56de1\u8868\u793a\u66f4\u65b0\n \u8fd4\u56de2\u8868\u793a\u589e\u52a0","docstring_tokens":[":","param","key",":",":","param","value",":",":","return",":","\u6839\u636e\u7ed9\u5b9a\u5b57\u5178\u4e2d\u7684\u67d0\u4e2a\u952e\u503c\u5bf9\u8ddf\u65b0\u6240\u5728list","\u4ee5\u4fdd\u8bc1list\u4e2d\u5143\u7d20\u7684\u552f\u4e00\u6027","\u8fd4\u56de0\u8868\u793a\u5931\u8d25","\u8fd4\u56de1\u8868\u793a\u66f4\u65b0","\u8fd4\u56de2\u8868\u793a\u589e\u52a0"],"function":"def update_dict_list_by_kv(old_list, element, key='id'):\n \"\"\"\n :param key:\n :param value:\n :return:\u6839\u636e\u7ed9\u5b9a\u5b57\u5178\u4e2d\u7684\u67d0\u4e2a\u952e\u503c\u5bf9\u8ddf\u65b0\u6240\u5728list, \u4ee5\u4fdd\u8bc1list\u4e2d\u5143\u7d20\u7684\u552f\u4e00\u6027\n \u8fd4\u56de0\u8868\u793a\u5931\u8d25\n \u8fd4\u56de1\u8868\u793a\u66f4\u65b0\n \u8fd4\u56de2\u8868\u793a\u589e\u52a0\n \"\"\"\n if key not in element:\n logger.warning(\"key\u4e0d\u5b58\u5728\u66f4\u65b0list\u5931\u8d25%s\"%(str(key)))\n return 0\n for ele in old_list:\n if ele[key] == element[key]:\n old_list[old_list.index(ele)] = element\n return 1\n old_list.append(element)\n return 2","function_tokens":["def","update_dict_list_by_kv","(","old_list",",","element",",","key","=","'id'",")",":","if","key","not","in","element",":","logger",".","warning","(","\"key\u4e0d\u5b58\u5728\u66f4\u65b0list\u5931\u8d25%s\"%(str(key)))","","","","","","","","","return","0","for","ele","in","old_list",":","if","ele","[","key","]","==","element","[","key","]",":","old_list","[","old_list",".","index","(","ele",")","]","=","element","return","1","old_list",".","append","(","element",")","return","2"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L219-L236"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.get_queue_by_kv","parameters":"(cls, **kwargs)","argument_list":"","return_statement":"return queue_list","docstring":":param valye:\n :return:\u901a\u8fc7\u7279\u5b9a\u7684\u952e\u503c\u5bf9\u7ec4\u5408\u83b7\u53d6\u5408\u9002\u7684\u961f\u5217","docstring_summary":":param valye:\n :return:\u901a\u8fc7\u7279\u5b9a\u7684\u952e\u503c\u5bf9\u7ec4\u5408\u83b7\u53d6\u5408\u9002\u7684\u961f\u5217","docstring_tokens":[":","param","valye",":",":","return",":","\u901a\u8fc7\u7279\u5b9a\u7684\u952e\u503c\u5bf9\u7ec4\u5408\u83b7\u53d6\u5408\u9002\u7684\u961f\u5217"],"function":"def get_queue_by_kv(cls, **kwargs):\n \"\"\"\n :param valye:\n :return:\u901a\u8fc7\u7279\u5b9a\u7684\u952e\u503c\u5bf9\u7ec4\u5408\u83b7\u53d6\u5408\u9002\u7684\u961f\u5217\n \"\"\"\n queue_gen = DBQ.col.find(kwargs)\n queue_list = []\n for queue in queue_gen:\n queue_list.append(queue)\n return queue_list","function_tokens":["def","get_queue_by_kv","(","cls",",","*","*","kwargs",")",":","queue_gen","=","DBQ",".","col",".","find","(","kwargs",")","queue_list","=","[","]","for","queue","in","queue_gen",":","queue_list",".","append","(","queue",")","return","queue_list"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L239-L248"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.delete_all_queue","parameters":"(cls)","argument_list":"","return_statement":"","docstring":":return:\u5220\u9664\u6240\u6709\u961f\u5217","docstring_summary":":return:\u5220\u9664\u6240\u6709\u961f\u5217","docstring_tokens":[":","return",":","\u5220\u9664\u6240\u6709\u961f\u5217"],"function":"def delete_all_queue(cls):\n \"\"\"\n :return:\u5220\u9664\u6240\u6709\u961f\u5217\n \"\"\"\n DBQ.col.delete_many()","function_tokens":["def","delete_all_queue","(","cls",")",":","DBQ",".","col",".","delete_many","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L252-L256"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/tools\/data_queue.py","language":"python","identifier":"DBQ.delete_queue","parameters":"(cls,name,queue_type)","argument_list":"","return_statement":"","docstring":":param name: \u961f\u5217\u540d\u79f0\n :param queue_type: \u961f\u5217\u7c7b\u578b\n :return: \u83b7\u53d6\u6307\u5b9a\u540d\u79f0\u548c\u7c7b\u578b\u7684\u961f\u5217","docstring_summary":":param name: \u961f\u5217\u540d\u79f0\n :param queue_type: \u961f\u5217\u7c7b\u578b\n :return: \u83b7\u53d6\u6307\u5b9a\u540d\u79f0\u548c\u7c7b\u578b\u7684\u961f\u5217","docstring_tokens":[":","param","name",":","\u961f\u5217\u540d\u79f0",":","param","queue_type",":","\u961f\u5217\u7c7b\u578b",":","return",":","\u83b7\u53d6\u6307\u5b9a\u540d\u79f0\u548c\u7c7b\u578b\u7684\u961f\u5217"],"function":"def delete_queue(cls,name,queue_type):\n \"\"\"\n :param name: \u961f\u5217\u540d\u79f0\n :param queue_type: \u961f\u5217\u7c7b\u578b\n :return: \u83b7\u53d6\u6307\u5b9a\u540d\u79f0\u548c\u7c7b\u578b\u7684\u961f\u5217\n \"\"\"\n DBQ.col.delete_one({'name':name,'queue_type':queue_type})","function_tokens":["def","delete_queue","(","cls",",","name",",","queue_type",")",":","DBQ",".","col",".","delete_one","(","{","'name'",":","name",",","'queue_type'",":","queue_type","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/tools\/data_queue.py#L259-L265"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/meta_data.py","language":"python","identifier":"insert_article_metadata","parameters":"(nickname, update_log)","argument_list":"","return_statement":"","docstring":":param nickname: \u66f4\u65b0\u7684\u516c\u4f17\u53f7\u6635\u79f0\n :param update_log: \u66f4\u65b0\u8be6\u7ec6\u65e5\u5fd7\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u5360\u7528\u4e00\u884c\u8bb0\u5f55","docstring_summary":":param nickname: \u66f4\u65b0\u7684\u516c\u4f17\u53f7\u6635\u79f0\n :param update_log: \u66f4\u65b0\u8be6\u7ec6\u65e5\u5fd7\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u5360\u7528\u4e00\u884c\u8bb0\u5f55","docstring_tokens":[":","param","nickname",":","\u66f4\u65b0\u7684\u516c\u4f17\u53f7\u6635\u79f0",":","param","update_log",":","\u66f4\u65b0\u8be6\u7ec6\u65e5\u5fd7",":","return",":","\u4e00\u4e2a\u516c\u4f17\u53f7\u5360\u7528\u4e00\u884c\u8bb0\u5f55"],"function":"def insert_article_metadata(nickname, update_log):\n \"\"\"\n :param nickname: \u66f4\u65b0\u7684\u516c\u4f17\u53f7\u6635\u79f0\n :param update_log: \u66f4\u65b0\u8be6\u7ec6\u65e5\u5fd7\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u5360\u7528\u4e00\u884c\u8bb0\u5f55\n \"\"\"\n metadata = col.find_one({'nickname':nickname})\n if type(metadata) is dict:\n metadata['update_log_list'].append(update_log)\n col.update_one({'nickname':nickname},{\"$set\":metadata})\n # metadata\u4e0d\u5b58\u5728\n else:\n metadata = copy(meta_data_scheme)\n metadata['nickname'] = nickname\n metadata['update_log_list'] = [update_log]\n col.insert_one(metadata)","function_tokens":["def","insert_article_metadata","(","nickname",",","update_log",")",":","metadata","=","col",".","find_one","(","{","'nickname'",":","nickname","}",")","if","type","(","metadata",")","is","dict",":","metadata","[","'update_log_list'","]",".","append","(","update_log",")","col",".","update_one","(","{","'nickname'",":","nickname","}",",","{","\"$set\"",":","metadata","}",")","# metadata\u4e0d\u5b58\u5728","else",":","metadata","=","copy","(","meta_data_scheme",")","metadata","[","'nickname'","]","=","nickname","metadata","[","'update_log_list'","]","=","[","update_log","]","col",".","insert_one","(","metadata",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/meta_data.py#L13-L28"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/meta_data.py","language":"python","identifier":"get_article_metadata","parameters":"(nickname=None, all=True)","argument_list":"","return_statement":"return data","docstring":":param nickname:\u6307\u5b9a\u8d26\u53f7\u7684\u65e5\u5fd7 None\u4e3a\u5168\u90e8\u8d26\u53f7\n :param all:True\u5168\u90e8\u65e5\u5fd7 False:\u6700\u540e\u4e00\u6b21\u66f4\u65b0\u65e5\u5fd7\n :return: \u83b7\u53d6\u516c\u4f17\u53f7\u6587\u7ae0\u5e73\u722c\u53d6\u7684\u65e5\u5fd7\u4fe1\u606f","docstring_summary":":param nickname:\u6307\u5b9a\u8d26\u53f7\u7684\u65e5\u5fd7 None\u4e3a\u5168\u90e8\u8d26\u53f7\n :param all:True\u5168\u90e8\u65e5\u5fd7 False:\u6700\u540e\u4e00\u6b21\u66f4\u65b0\u65e5\u5fd7\n :return: \u83b7\u53d6\u516c\u4f17\u53f7\u6587\u7ae0\u5e73\u722c\u53d6\u7684\u65e5\u5fd7\u4fe1\u606f","docstring_tokens":[":","param","nickname",":","\u6307\u5b9a\u8d26\u53f7\u7684\u65e5\u5fd7","None\u4e3a\u5168\u90e8\u8d26\u53f7",":","param","all",":","True\u5168\u90e8\u65e5\u5fd7","False",":","\u6700\u540e\u4e00\u6b21\u66f4\u65b0\u65e5\u5fd7",":","return",":","\u83b7\u53d6\u516c\u4f17\u53f7\u6587\u7ae0\u5e73\u722c\u53d6\u7684\u65e5\u5fd7\u4fe1\u606f"],"function":"def get_article_metadata(nickname=None, all=True):\n \"\"\"\n :param nickname:\u6307\u5b9a\u8d26\u53f7\u7684\u65e5\u5fd7 None\u4e3a\u5168\u90e8\u8d26\u53f7\n :param all:True\u5168\u90e8\u65e5\u5fd7 False:\u6700\u540e\u4e00\u6b21\u66f4\u65b0\u65e5\u5fd7\n :return: \u83b7\u53d6\u516c\u4f17\u53f7\u6587\u7ae0\u5e73\u722c\u53d6\u7684\u65e5\u5fd7\u4fe1\u606f\n \"\"\"\n data = {}\n metadata = []\n if nickname is not None:\n metadata = [col.find_one({'nickname':nickname})]\n else:\n for md in col.find():\n metadata.append(md)\n for item in metadata:\n if all:data[item['nickname']] = item['update_log_list']\n else :data[item['nickname']] = item['update_log_list'][-1]\n return data","function_tokens":["def","get_article_metadata","(","nickname","=","None",",","all","=","True",")",":","data","=","{","}","metadata","=","[","]","if","nickname","is","not","None",":","metadata","=","[","col",".","find_one","(","{","'nickname'",":","nickname","}",")","]","else",":","for","md","in","col",".","find","(",")",":","metadata",".","append","(","md",")","for","item","in","metadata",":","if","all",":","data","[","item","[","'nickname'","]","]","=","item","[","'update_log_list'","]","else",":","data","[","item","[","'nickname'","]","]","=","item","[","'update_log_list'","]","[","-","1","]","return","data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/meta_data.py#L31-L47"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/meta_data.py","language":"python","identifier":"delete_article_metadata","parameters":"(nickname)","argument_list":"","return_statement":"","docstring":":param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return: \u5220\u9664\u6307\u5b9a\u516c\u4f17\u53f7\u7684\u5fae\u4fe1\u722c\u53d6\u65e5\u5fd7\u4fe1\u606f","docstring_summary":":param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return: \u5220\u9664\u6307\u5b9a\u516c\u4f17\u53f7\u7684\u5fae\u4fe1\u722c\u53d6\u65e5\u5fd7\u4fe1\u606f","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","return",":","\u5220\u9664\u6307\u5b9a\u516c\u4f17\u53f7\u7684\u5fae\u4fe1\u722c\u53d6\u65e5\u5fd7\u4fe1\u606f"],"function":"def delete_article_metadata(nickname):\n \"\"\"\n :param nickname: \u516c\u4f17\u53f7\u6635\u79f0\n :return: \u5220\u9664\u6307\u5b9a\u516c\u4f17\u53f7\u7684\u5fae\u4fe1\u722c\u53d6\u65e5\u5fd7\u4fe1\u606f\n \"\"\"\n col.delete_one({'nickname':nickname})","function_tokens":["def","delete_article_metadata","(","nickname",")",":","col",".","delete_one","(","{","'nickname'",":","nickname","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/meta_data.py#L50-L55"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/meta_data.py","language":"python","identifier":"update_history","parameters":"()","argument_list":"","return_statement":"","docstring":":return:\u4e3a\u6b64\u524d\u901a\u8fc7\u624b\u52a8\u722c\u53d6\u7684\u6587\u7ae0\u521b\u5efametadata","docstring_summary":":return:\u4e3a\u6b64\u524d\u901a\u8fc7\u624b\u52a8\u722c\u53d6\u7684\u6587\u7ae0\u521b\u5efametadata","docstring_tokens":[":","return",":","\u4e3a\u6b64\u524d\u901a\u8fc7\u624b\u52a8\u722c\u53d6\u7684\u6587\u7ae0\u521b\u5efametadata"],"function":"def update_history():\n \"\"\"\n :return:\u4e3a\u6b64\u524d\u901a\u8fc7\u624b\u52a8\u722c\u53d6\u7684\u6587\u7ae0\u521b\u5efametadata\n \"\"\"\n from db import WeixinDB\n from datetime import datetime\n wxdb = WeixinDB()\n nicknames = wxdb.get_all_nickname(is_count=True)\n for item in nicknames:\n if item[0] not in ['queue','crawler_metadata']:\n insert_article_metadata(item[0],{'date':datetime.now(),'articles_num':item[1]})","function_tokens":["def","update_history","(",")",":","from","db","import","WeixinDB","from","datetime","import","datetime","wxdb","=","WeixinDB","(",")","nicknames","=","wxdb",".","get_all_nickname","(","is_count","=","True",")","for","item","in","nicknames",":","if","item","[","0","]","not","in","[","'queue'",",","'crawler_metadata'","]",":","insert_article_metadata","(","item","[","0","]",",","{","'date'",":","datetime",".","now","(",")",",","'articles_num'",":","item","[","1","]","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/meta_data.py#L58-L68"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"update_article_from_template","parameters":"(article_seg)","argument_list":"","return_statement":"return article","docstring":":param article_seg: \u542b\u6709\u4e00\u6761article\u90e8\u5206\u6216\u8005\u5168\u90e8\u7684\u6570\u636e\n :return:\u6839\u636earticle_scheme\u4e2d\u6307\u5b9a\u7684\u5b57\u6bb5\u63d0\u53d6article_seg\u4e2d\u7684\u6570\u636e","docstring_summary":":param article_seg: \u542b\u6709\u4e00\u6761article\u90e8\u5206\u6216\u8005\u5168\u90e8\u7684\u6570\u636e\n :return:\u6839\u636earticle_scheme\u4e2d\u6307\u5b9a\u7684\u5b57\u6bb5\u63d0\u53d6article_seg\u4e2d\u7684\u6570\u636e","docstring_tokens":[":","param","article_seg",":","\u542b\u6709\u4e00\u6761article\u90e8\u5206\u6216\u8005\u5168\u90e8\u7684\u6570\u636e",":","return",":","\u6839\u636earticle_scheme\u4e2d\u6307\u5b9a\u7684\u5b57\u6bb5\u63d0\u53d6article_seg\u4e2d\u7684\u6570\u636e"],"function":"def update_article_from_template(article_seg):\n \"\"\"\n :param article_seg: \u542b\u6709\u4e00\u6761article\u90e8\u5206\u6216\u8005\u5168\u90e8\u7684\u6570\u636e\n :return:\u6839\u636earticle_scheme\u4e2d\u6307\u5b9a\u7684\u5b57\u6bb5\u63d0\u53d6article_seg\u4e2d\u7684\u6570\u636e\n \"\"\"\n article = {}\n for key in article_scheme:\n if key in article_seg:\n article[key] = article_seg[key]\n return article","function_tokens":["def","update_article_from_template","(","article_seg",")",":","article","=","{","}","for","key","in","article_scheme",":","if","key","in","article_seg",":","article","[","key","]","=","article_seg","[","key","]","return","article"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L38-L47"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"insert_one","parameters":"(nickname, article)","argument_list":"","return_statement":"return col.insert_one(article).inserted_id","docstring":":param nickname:\n :param article: dict data\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u516c\u4f17\u53f7\u6587\u7ae0\u6570\u636e","docstring_summary":":param nickname:\n :param article: dict data\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u516c\u4f17\u53f7\u6587\u7ae0\u6570\u636e","docstring_tokens":[":","param","nickname",":",":","param","article",":","dict","data",":","return",":","\u5728nickname","collection\u4e2d\u63d2\u5165\u4e00\u516c\u4f17\u53f7\u6587\u7ae0\u6570\u636e"],"function":"def insert_one(nickname, article):\n \"\"\"\n :param nickname:\n :param article: dict data\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u516c\u4f17\u53f7\u6587\u7ae0\u6570\u636e\n \"\"\"\n col = db_instance[nickname]\n return col.insert_one(article).inserted_id","function_tokens":["def","insert_one","(","nickname",",","article",")",":","col","=","db_instance","[","nickname","]","return","col",".","insert_one","(","article",")",".","inserted_id"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L50-L57"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"update_one","parameters":"(nickname, articel)","argument_list":"","return_statement":"return op_result","docstring":":param nickname:\n :param articel:\n :return: \u6839\u636earticle\u4e2d\u7684content_url\u66f4\u65b0\u6587\u7ae0\u6570\u636e","docstring_summary":":param nickname:\n :param articel:\n :return: \u6839\u636earticle\u4e2d\u7684content_url\u66f4\u65b0\u6587\u7ae0\u6570\u636e","docstring_tokens":[":","param","nickname",":",":","param","articel",":",":","return",":","\u6839\u636earticle\u4e2d\u7684content_url\u66f4\u65b0\u6587\u7ae0\u6570\u636e"],"function":"def update_one(nickname, articel):\n \"\"\"\n :param nickname:\n :param articel:\n :return: \u6839\u636earticle\u4e2d\u7684content_url\u66f4\u65b0\u6587\u7ae0\u6570\u636e\n \"\"\"\n op_result = ''\n # \u5df2\u7ecf\u5220\u9664\u7684\u6587\u7ae0\u4e0d\u5b58\u5728content_url\u5c5e\u6027 \u76f4\u63a5\u8fd4\u56de\u5c40\n if articel[\"content_url\"] is \"\":\n op_result = 'ERROR'\n return op_result\n col = db_instance[nickname]\n result = col.find_one({\"content_url\":articel['content_url']})\n if type(result) is dict:\n # \u6570\u636e\u5b58\u5728\u53ef\u4ee5\u66f4\u65b0\n col.update_one({\"content_url\":articel['content_url']},\n {\"$set\":articel})\n op_result = 'UPDATE'\n else:\n # \u6570\u636e\u4e0d\u5b58\u5728\u8c03\u7528\u63d2\u5165\n insert_one(nickname, articel)\n op_result = 'INSERT'\n return op_result","function_tokens":["def","update_one","(","nickname",",","articel",")",":","op_result","=","''","# \u5df2\u7ecf\u5220\u9664\u7684\u6587\u7ae0\u4e0d\u5b58\u5728content_url\u5c5e\u6027 \u76f4\u63a5\u8fd4\u56de\u5c40","if","articel","[","\"content_url\"","]","is","\"\"",":","op_result","=","'ERROR'","return","op_result","col","=","db_instance","[","nickname","]","result","=","col",".","find_one","(","{","\"content_url\"",":","articel","[","'content_url'","]","}",")","if","type","(","result",")","is","dict",":","# \u6570\u636e\u5b58\u5728\u53ef\u4ee5\u66f4\u65b0","col",".","update_one","(","{","\"content_url\"",":","articel","[","'content_url'","]","}",",","{","\"$set\"",":","articel","}",")","op_result","=","'UPDATE'","else",":","# \u6570\u636e\u4e0d\u5b58\u5728\u8c03\u7528\u63d2\u5165","insert_one","(","nickname",",","articel",")","op_result","=","'INSERT'","return","op_result"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L59-L81"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"insert_many","parameters":"(nickname, articles, check_exist=True)","argument_list":"","return_statement":"return has_update","docstring":":param nickname:\n :param articles:article lsit\n :param check_exist:\u5982\u5426\u9700\u8981\u6839\u636econtent_url\u5224\u91cd\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u4e2alist\u7684\u6587\u7ae0","docstring_summary":":param nickname:\n :param articles:article lsit\n :param check_exist:\u5982\u5426\u9700\u8981\u6839\u636econtent_url\u5224\u91cd\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u4e2alist\u7684\u6587\u7ae0","docstring_tokens":[":","param","nickname",":",":","param","articles",":","article","lsit",":","param","check_exist",":","\u5982\u5426\u9700\u8981\u6839\u636econtent_url\u5224\u91cd",":","return",":","\u5728nickname","collection\u4e2d\u63d2\u5165\u4e00\u4e2alist\u7684\u6587\u7ae0"],"function":"def insert_many(nickname, articles, check_exist=True):\n \"\"\"\n :param nickname:\n :param articles:article lsit\n :param check_exist:\u5982\u5426\u9700\u8981\u6839\u636econtent_url\u5224\u91cd\n :return: \u5728nickname collection\u4e2d\u63d2\u5165\u4e00\u4e2alist\u7684\u6587\u7ae0\n \"\"\"\n # \u662f\u5426\u5b58\u5728\u88ab\u66f4\u65b0\u7684\u8bb0\u5f55\n has_update = False\n if check_exist==False:\n col = db_instance[nickname]\n col.insert_many(articles)\n else:\n for article in articles:\n result = update_one(nickname, article)\n if result == 'UPDATE':\n has_update = True\n return has_update","function_tokens":["def","insert_many","(","nickname",",","articles",",","check_exist","=","True",")",":","# \u662f\u5426\u5b58\u5728\u88ab\u66f4\u65b0\u7684\u8bb0\u5f55","has_update","=","False","if","check_exist","==","False",":","col","=","db_instance","[","nickname","]","col",".","insert_many","(","articles",")","else",":","for","article","in","articles",":","result","=","update_one","(","nickname",",","article",")","if","result","==","'UPDATE'",":","has_update","=","True","return","has_update"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L84-L101"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"count","parameters":"(nickname)","argument_list":"","return_statement":"return db_instance[nickname].count()","docstring":":param nickname:\n :return: \u8ba1\u7b97\u5f53\u524d\u516c\u4f17\u53f7\u7684\u6587\u7ae0\u6570\u91cf","docstring_summary":":param nickname:\n :return: \u8ba1\u7b97\u5f53\u524d\u516c\u4f17\u53f7\u7684\u6587\u7ae0\u6570\u91cf","docstring_tokens":[":","param","nickname",":",":","return",":","\u8ba1\u7b97\u5f53\u524d\u516c\u4f17\u53f7\u7684\u6587\u7ae0\u6570\u91cf"],"function":"def count(nickname):\n \"\"\"\n :param nickname:\n :return: \u8ba1\u7b97\u5f53\u524d\u516c\u4f17\u53f7\u7684\u6587\u7ae0\u6570\u91cf\n \"\"\"\n return db_instance[nickname].count()","function_tokens":["def","count","(","nickname",")",":","return","db_instance","[","nickname","]",".","count","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L104-L109"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"delete","parameters":"(nickname, **kwargs)","argument_list":"","return_statement":"","docstring":":param nickname:\n :param kwargs: \u7528\u5b57\u5178\u8868\u793a\u7684\u8fc7\u6ee4\u5668\n :return: \u6839\u636ematch\u4e2d\u63d0\u4f9b\u7684\u7b26\u5408\u4fe1\u606f\u5220\u9664\u6587\u7ae0 \u652f\u6301\u5168\u90e8\u5220\u9664","docstring_summary":":param nickname:\n :param kwargs: \u7528\u5b57\u5178\u8868\u793a\u7684\u8fc7\u6ee4\u5668\n :return: \u6839\u636ematch\u4e2d\u63d0\u4f9b\u7684\u7b26\u5408\u4fe1\u606f\u5220\u9664\u6587\u7ae0 \u652f\u6301\u5168\u90e8\u5220\u9664","docstring_tokens":[":","param","nickname",":",":","param","kwargs",":","\u7528\u5b57\u5178\u8868\u793a\u7684\u8fc7\u6ee4\u5668",":","return",":","\u6839\u636ematch\u4e2d\u63d0\u4f9b\u7684\u7b26\u5408\u4fe1\u606f\u5220\u9664\u6587\u7ae0","\u652f\u6301\u5168\u90e8\u5220\u9664"],"function":"def delete(nickname, **kwargs):\n \"\"\"\n :param nickname:\n :param kwargs: \u7528\u5b57\u5178\u8868\u793a\u7684\u8fc7\u6ee4\u5668\n :return: \u6839\u636ematch\u4e2d\u63d0\u4f9b\u7684\u7b26\u5408\u4fe1\u606f\u5220\u9664\u6587\u7ae0 \u652f\u6301\u5168\u90e8\u5220\u9664\n \"\"\"\n col = db_instance[nickname]\n col.delete_many(kwargs)","function_tokens":["def","delete","(","nickname",",","*","*","kwargs",")",":","col","=","db_instance","[","nickname","]","col",".","delete_many","(","kwargs",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L112-L119"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"find_one","parameters":"(nickname,content_url)","argument_list":"","return_statement":"return result","docstring":":param nickname:\n :param content_url:\n :return:","docstring_summary":":param nickname:\n :param content_url:\n :return:","docstring_tokens":[":","param","nickname",":",":","param","content_url",":",":","return",":"],"function":"def find_one(nickname,content_url):\n \"\"\"\n :param nickname:\n :param content_url:\n :return:\n \"\"\"\n col = db_instance[nickname]\n result = col.find_one({'content_url':content_url})\n return result","function_tokens":["def","find_one","(","nickname",",","content_url",")",":","col","=","db_instance","[","nickname","]","result","=","col",".","find_one","(","{","'content_url'",":","content_url","}",")","return","result"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L122-L130"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"drop_collection","parameters":"(nickname)","argument_list":"","return_statement":"return nickname","docstring":":param nickname:\n :return: \u5220\u9664collection","docstring_summary":":param nickname:\n :return: \u5220\u9664collection","docstring_tokens":[":","param","nickname",":",":","return",":","\u5220\u9664collection"],"function":"def drop_collection(nickname):\n \"\"\"\n :param nickname:\n :return: \u5220\u9664collection\n \"\"\"\n db_instance.drop_collection(nickname)\n return nickname","function_tokens":["def","drop_collection","(","nickname",")",":","db_instance",".","drop_collection","(","nickname",")","return","nickname"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L133-L139"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"get_collection_article","parameters":"(nickname,**kwargs)","argument_list":"","return_statement":"","docstring":":param nickname: \n :param kwargs: \u4f8b\u5982\u627e\u51fa\u4e0d\u5b58\u5728article\u5b57\u6bb5\u7684\u6240\u6709\u6570\u636e {\"article\":{\"$exists\": False}}\n :return: \u4ee5\u751f\u6210\u5668\u7684\u5f62\u5f0f\u8fd4\u56de\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6216\u8005\u90e8\u5206\u6570\u636e","docstring_summary":":param nickname: \n :param kwargs: \u4f8b\u5982\u627e\u51fa\u4e0d\u5b58\u5728article\u5b57\u6bb5\u7684\u6240\u6709\u6570\u636e {\"article\":{\"$exists\": False}}\n :return: \u4ee5\u751f\u6210\u5668\u7684\u5f62\u5f0f\u8fd4\u56de\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6216\u8005\u90e8\u5206\u6570\u636e","docstring_tokens":[":","param","nickname",":",":","param","kwargs",":","\u4f8b\u5982\u627e\u51fa\u4e0d\u5b58\u5728article\u5b57\u6bb5\u7684\u6240\u6709\u6570\u636e","{","article",":","{","$exists",":","False","}}",":","return",":","\u4ee5\u751f\u6210\u5668\u7684\u5f62\u5f0f\u8fd4\u56de\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6216\u8005\u90e8\u5206\u6570\u636e"],"function":"def get_collection_article(nickname,**kwargs):\n \"\"\"\n :param nickname: \n :param kwargs: \u4f8b\u5982\u627e\u51fa\u4e0d\u5b58\u5728article\u5b57\u6bb5\u7684\u6240\u6709\u6570\u636e {\"article\":{\"$exists\": False}}\n :return: \u4ee5\u751f\u6210\u5668\u7684\u5f62\u5f0f\u8fd4\u56de\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6216\u8005\u90e8\u5206\u6570\u636e\n \"\"\"\n col = db_instance[nickname]\n articles = col.find(kwargs)\n for article in articles:\n yield article","function_tokens":["def","get_collection_article","(","nickname",",","*","*","kwargs",")",":","col","=","db_instance","[","nickname","]","articles","=","col",".","find","(","kwargs",")","for","article","in","articles",":","yield","article"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L142-L151"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/db\/__init__.py","language":"python","identifier":"WeixinDB.get_all_nickname","parameters":"(is_count=False)","argument_list":"","return_statement":"return nicknames_count","docstring":":param is_count:\u662f\u5426\u9700\u8981\u8ba1\u7b97collection\u4e2d\u7684\u6570\u636e\u6570\u91cf\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u662f\u4e00\u4e2acollection \u8fd4\u56de\u5168\u90e8\u7684collection\u540d\u79f0","docstring_summary":":param is_count:\u662f\u5426\u9700\u8981\u8ba1\u7b97collection\u4e2d\u7684\u6570\u636e\u6570\u91cf\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u662f\u4e00\u4e2acollection \u8fd4\u56de\u5168\u90e8\u7684collection\u540d\u79f0","docstring_tokens":[":","param","is_count",":","\u662f\u5426\u9700\u8981\u8ba1\u7b97collection\u4e2d\u7684\u6570\u636e\u6570\u91cf",":","return",":","\u4e00\u4e2a\u516c\u4f17\u53f7\u662f\u4e00\u4e2acollection","\u8fd4\u56de\u5168\u90e8\u7684collection\u540d\u79f0"],"function":"def get_all_nickname(is_count=False):\n \"\"\"\n :param is_count:\u662f\u5426\u9700\u8981\u8ba1\u7b97collection\u4e2d\u7684\u6570\u636e\u6570\u91cf\n :return: \u4e00\u4e2a\u516c\u4f17\u53f7\u662f\u4e00\u4e2acollection \u8fd4\u56de\u5168\u90e8\u7684collection\u540d\u79f0\n \"\"\"\n nicknames = db_instance.collection_names()\n if is_count is False:\n return nicknames\n else:\n nicknames_count = []\n for nickname in nicknames:\n nicknames_count.append((nickname,count(nickname)))\n return nicknames_count","function_tokens":["def","get_all_nickname","(","is_count","=","False",")",":","nicknames","=","db_instance",".","collection_names","(",")","if","is_count","is","False",":","return","nicknames","else",":","nicknames_count","=","[","]","for","nickname","in","nicknames",":","nicknames_count",".","append","(","(","nickname",",","count","(","nickname",")",")",")","return","nicknames_count"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/db\/__init__.py#L161-L173"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/AllArticles.py","language":"python","identifier":"get_all_articles_data","parameters":"(nickname)","argument_list":"","return_statement":"return data","docstring":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0\u5217\u8868\n {'title':'\u516c\u4f17\u53f7\u540d\u79f0','articles':[{},{},{}]}","docstring_summary":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0\u5217\u8868\n {'title':'\u516c\u4f17\u53f7\u540d\u79f0','articles':[{},{},{}]}","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","return",":","\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0\u5217\u8868","{","title",":","\u516c\u4f17\u53f7\u540d\u79f0","articles",":","[","{}","{}","{}","]","}"],"function":"def get_all_articles_data(nickname):\n \"\"\"\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :return:\u4e00\u4e2a\u516c\u4f17\u53f7\u7684\u5168\u90e8\u6587\u7ae0\u5217\u8868\n {'title':'\u516c\u4f17\u53f7\u540d\u79f0','articles':[{},{},{}]}\n \"\"\"\n use_keys = ['article_id',\n 'p_date',\n 'read_num',\n 'like_num',\n 'reward_num',\n 'comment_num',\n 'author',\n 'mov',\n 'title',\n 'content_url']\n data = {}\n data['title'] = nickname\n data['articles'] = []\n articles = get_collection_article(nickname)\n id_counter = 0\n for article in articles:\n if 'title' not in article:\n continue\n id_counter += 1\n use_data = {}\n # use_data = dict((k, article[k]) for k in use_keys)\n for k in use_keys:\n if k in article:\n use_data[k] = article[k]\n else:\n use_data[k] = '-'\n # \u53d1\u6587\u65f6\u95f4\u683c\u5f0f\u8f6c\u5316\n use_data['p_date'] = use_data['p_date'].strftime(\"%Y\/%m\/%d\")\n use_data['article_id'] = id_counter\n data['articles'].append(use_data)\n return data","function_tokens":["def","get_all_articles_data","(","nickname",")",":","use_keys","=","[","'article_id'",",","'p_date'",",","'read_num'",",","'like_num'",",","'reward_num'",",","'comment_num'",",","'author'",",","'mov'",",","'title'",",","'content_url'","]","data","=","{","}","data","[","'title'","]","=","nickname","data","[","'articles'","]","=","[","]","articles","=","get_collection_article","(","nickname",")","id_counter","=","0","for","article","in","articles",":","if","'title'","not","in","article",":","continue","id_counter","+=","1","use_data","=","{","}","# use_data = dict((k, article[k]) for k in use_keys)","for","k","in","use_keys",":","if","k","in","article",":","use_data","[","k","]","=","article","[","k","]","else",":","use_data","[","k","]","=","'-'","# \u53d1\u6587\u65f6\u95f4\u683c\u5f0f\u8f6c\u5316","use_data","[","'p_date'","]","=","use_data","[","'p_date'","]",".","strftime","(","\"%Y\/%m\/%d\"",")","use_data","[","'article_id'","]","=","id_counter","data","[","'articles'","]",".","append","(","use_data",")","return","data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/AllArticles.py#L4-L40"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.allStatistic","parameters":"(self)","argument_list":"","return_statement":"return df_move","docstring":"\u9488\u5bf9\u4e3b\u526f\u6587\u7ae0\u5206\u522b\u505a\u7edf\u8ba1\uff0c\u8fd4\u56de\u7684dataframe\u7684collum\u6709\u4e24\u5c42\u6df1\u5ea6\u7b2c\u4e00\u5c42\u662f\u4e3b\u526f\uff08\u53d1\u6587\u4f4d\u7f6e\uff09\u7b2c\u4e8c\u5c42\u662f\u7edf\u8ba1\u6570\u5b57","docstring_summary":"\u9488\u5bf9\u4e3b\u526f\u6587\u7ae0\u5206\u522b\u505a\u7edf\u8ba1\uff0c\u8fd4\u56de\u7684dataframe\u7684collum\u6709\u4e24\u5c42\u6df1\u5ea6\u7b2c\u4e00\u5c42\u662f\u4e3b\u526f\uff08\u53d1\u6587\u4f4d\u7f6e\uff09\u7b2c\u4e8c\u5c42\u662f\u7edf\u8ba1\u6570\u5b57","docstring_tokens":["\u9488\u5bf9\u4e3b\u526f\u6587\u7ae0\u5206\u522b\u505a\u7edf\u8ba1\uff0c\u8fd4\u56de\u7684dataframe\u7684collum\u6709\u4e24\u5c42\u6df1\u5ea6\u7b2c\u4e00\u5c42\u662f\u4e3b\u526f\uff08\u53d1\u6587\u4f4d\u7f6e\uff09\u7b2c\u4e8c\u5c42\u662f\u7edf\u8ba1\u6570\u5b57"],"function":"def allStatistic(self):\n '''\n \u9488\u5bf9\u4e3b\u526f\u6587\u7ae0\u5206\u522b\u505a\u7edf\u8ba1\uff0c\u8fd4\u56de\u7684dataframe\u7684collum\u6709\u4e24\u5c42\u6df1\u5ea6\u7b2c\u4e00\u5c42\u662f\u4e3b\u526f\uff08\u53d1\u6587\u4f4d\u7f6e\uff09\u7b2c\u4e8c\u5c42\u662f\u7edf\u8ba1\u6570\u5b57\n '''\n # \u8ba1\u7b97\u673aA\u5404\u9879\u6307\u6807\u7684\u5e73\u5747\u503c\n df_move = self.posts_df.groupby('mov')[['read','like','reward','comment']].describe(percentiles=[.5])\n return df_move","function_tokens":["def","allStatistic","(","self",")",":","# \u8ba1\u7b97\u673aA\u5404\u9879\u6307\u6807\u7684\u5e73\u5747\u503c","df_move","=","self",".","posts_df",".","groupby","(","'mov'",")","[","[","'read'",",","'like'",",","'reward'",",","'comment'","]","]",".","describe","(","percentiles","=","[",".5","]",")","return","df_move"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L62-L68"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.allMainDateRead","parameters":"(self)","argument_list":"","return_statement":"return main_posts_df.sort_values(by='date',ascending=False)","docstring":"\u8fd4\u56de\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e \u843d\u5dee\u6307\u6570\u4ec5\u4ec5\u9488\u5bf9\u4e3b\u6587\u7ae0\u6709\u610f\u4e49","docstring_summary":"\u8fd4\u56de\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e \u843d\u5dee\u6307\u6570\u4ec5\u4ec5\u9488\u5bf9\u4e3b\u6587\u7ae0\u6709\u610f\u4e49","docstring_tokens":["\u8fd4\u56de\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e","\u843d\u5dee\u6307\u6570\u4ec5\u4ec5\u9488\u5bf9\u4e3b\u6587\u7ae0\u6709\u610f\u4e49"],"function":"def allMainDateRead(self):\n '''\n \u8fd4\u56de\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e \u843d\u5dee\u6307\u6570\u4ec5\u4ec5\u9488\u5bf9\u4e3b\u6587\u7ae0\u6709\u610f\u4e49\n '''\n main_posts_df = self.posts_df.loc[self.posts_df['mov']==10][['id','title_cnt','url','date','read','like','comment','reward','deep_index']]\n # \u52a0\u5165\u4e0a\u4e00\u6b21\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\n main_posts_df['pre_read'] = main_posts_df.read.shift(-1)\n # \u843d\u5dee\u6307\u6570 \u4e0a\u6b21\u9605\u8bfb\u91cf\/\u672c\u6b21\u9605\u8bfb\u91cf*1000\n main_posts_df['fall_index'] = round((main_posts_df['pre_read']\/main_posts_df['read'])*1000,2)\n # \u6309\u53d1\u6587\u65f6\u95f4\u964d\u5e8f\u6392\u5e8f\n return main_posts_df.sort_values(by='date',ascending=False)","function_tokens":["def","allMainDateRead","(","self",")",":","main_posts_df","=","self",".","posts_df",".","loc","[","self",".","posts_df","[","'mov'","]","==","10","]","[","[","'id'",",","'title_cnt'",",","'url'",",","'date'",",","'read'",",","'like'",",","'comment'",",","'reward'",",","'deep_index'","]","]","# \u52a0\u5165\u4e0a\u4e00\u6b21\u6587\u7ae0\u7684\u9605\u8bfb\u91cf","main_posts_df","[","'pre_read'","]","=","main_posts_df",".","read",".","shift","(","-","1",")","# \u843d\u5dee\u6307\u6570 \u4e0a\u6b21\u9605\u8bfb\u91cf\/\u672c\u6b21\u9605\u8bfb\u91cf*1000","main_posts_df","[","'fall_index'","]","=","round","(","(","main_posts_df","[","'pre_read'","]","\/","main_posts_df","[","'read'","]",")","*","1000",",","2",")","# \u6309\u53d1\u6587\u65f6\u95f4\u964d\u5e8f\u6392\u5e8f","return","main_posts_df",".","sort_values","(","by","=","'date'",",","ascending","=","False",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L70-L80"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.dirPostsNumRelated","parameters":"(self)","argument_list":"","return_statement":"return dfd","docstring":"\u8fd4\u56de\u5404\u7c7b\u6587\u7ae0\u5728\u9605\u8bfb\u91cf\u4e0a\u7684\u7edf\u8ba1\u6570\u5b57 \u660e\u786e50%\u4f5c\u4e3a\u4e2d\u4f4d\u6570","docstring_summary":"\u8fd4\u56de\u5404\u7c7b\u6587\u7ae0\u5728\u9605\u8bfb\u91cf\u4e0a\u7684\u7edf\u8ba1\u6570\u5b57 \u660e\u786e50%\u4f5c\u4e3a\u4e2d\u4f4d\u6570","docstring_tokens":["\u8fd4\u56de\u5404\u7c7b\u6587\u7ae0\u5728\u9605\u8bfb\u91cf\u4e0a\u7684\u7edf\u8ba1\u6570\u5b57","\u660e\u786e50%\u4f5c\u4e3a\u4e2d\u4f4d\u6570"],"function":"def dirPostsNumRelated(self):\n '''\n \u8fd4\u56de\u5404\u7c7b\u6587\u7ae0\u5728\u9605\u8bfb\u91cf\u4e0a\u7684\u7edf\u8ba1\u6570\u5b57 \u660e\u786e50%\u4f5c\u4e3a\u4e2d\u4f4d\u6570\n '''\n dfd = {}\n dfd['mov'] = self.posts_df.groupby('mov').describe(percentiles=[.5])['read']\n dfd['week'] = self.posts_df.groupby('week').describe(percentiles=[.5])['read']\n dfd['hour'] = self.posts_df.groupby('hour').describe(percentiles=[.5])['read']\n return dfd","function_tokens":["def","dirPostsNumRelated","(","self",")",":","dfd","=","{","}","dfd","[","'mov'","]","=","self",".","posts_df",".","groupby","(","'mov'",")",".","describe","(","percentiles","=","[",".5","]",")","[","'read'","]","dfd","[","'week'","]","=","self",".","posts_df",".","groupby","(","'week'",")",".","describe","(","percentiles","=","[",".5","]",")","[","'read'","]","dfd","[","'hour'","]","=","self",".","posts_df",".","groupby","(","'hour'",")",".","describe","(","percentiles","=","[",".5","]",")","[","'read'","]","return","dfd"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L82-L90"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.factorsAndRead","parameters":"(self)","argument_list":"","return_statement":"return main_posts_df","docstring":"\u5c06posts\u4e2d\u53ef\u80fd\u548c\u9605\u8bfb\u91cf\u6709\u5173\u7684\u6240\u6709\u56e0\u7d20\u8fd4\u56de,\u5efa\u8bae\u4f7f\u7528\u6563\u70b9\u56fe\u8868\u793a","docstring_summary":"\u5c06posts\u4e2d\u53ef\u80fd\u548c\u9605\u8bfb\u91cf\u6709\u5173\u7684\u6240\u6709\u56e0\u7d20\u8fd4\u56de,\u5efa\u8bae\u4f7f\u7528\u6563\u70b9\u56fe\u8868\u793a","docstring_tokens":["\u5c06posts\u4e2d\u53ef\u80fd\u548c\u9605\u8bfb\u91cf\u6709\u5173\u7684\u6240\u6709\u56e0\u7d20\u8fd4\u56de","\u5efa\u8bae\u4f7f\u7528\u6563\u70b9\u56fe\u8868\u793a"],"function":"def factorsAndRead(self):\n '''\n \u5c06posts\u4e2d\u53ef\u80fd\u548c\u9605\u8bfb\u91cf\u6709\u5173\u7684\u6240\u6709\u56e0\u7d20\u8fd4\u56de,\u5efa\u8bae\u4f7f\u7528\u6563\u70b9\u56fe\u8868\u793a\n '''\n main_posts_df = self.posts_df.loc[self.posts_df['mov']==10][['id','read','like','title','pic','video','week','hour']]\n # \u52a0\u5165\u4e0a\u4e00\u6b21\u6587\u7ae0\u7684\u9605\u8bfb\u91cf\n main_posts_df['pre_read'] = main_posts_df.read.shift(-1)\n # \u843d\u5dee\u6307\u6570 \u4e0a\u6b21\u9605\u8bfb\u91cf\/\u672c\u6b21\u9605\u8bfb\u91cf*1000\n main_posts_df['fall_index'] = round((main_posts_df['pre_read']\/main_posts_df['read'])*1000,2)\n return main_posts_df","function_tokens":["def","factorsAndRead","(","self",")",":","main_posts_df","=","self",".","posts_df",".","loc","[","self",".","posts_df","[","'mov'","]","==","10","]","[","[","'id'",",","'read'",",","'like'",",","'title'",",","'pic'",",","'video'",",","'week'",",","'hour'","]","]","# \u52a0\u5165\u4e0a\u4e00\u6b21\u6587\u7ae0\u7684\u9605\u8bfb\u91cf","main_posts_df","[","'pre_read'","]","=","main_posts_df",".","read",".","shift","(","-","1",")","# \u843d\u5dee\u6307\u6570 \u4e0a\u6b21\u9605\u8bfb\u91cf\/\u672c\u6b21\u9605\u8bfb\u91cf*1000","main_posts_df","[","'fall_index'","]","=","round","(","(","main_posts_df","[","'pre_read'","]","\/","main_posts_df","[","'read'","]",")","*","1000",",","2",")","return","main_posts_df"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L92-L101"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.averageHourRead","parameters":"(self)","argument_list":"","return_statement":"return self.posts_df.groupby('hour').describe(percentiles=[.5])['read']","docstring":"\u4e00\u5929\u4e2d\u7684\u4e0d\u540c\u5c0f\u65f6\u6bb5\u53d1\u6587\u6570\u91cf\u5e76\u4e0d\u76f8\u540c,\u4ec5\u4ec5\u6bd4\u8f83\u53d1\u6587\u603b\u6570,\u548c\u603b\u9605\u8bfb\u91cf\u65e0\u6cd5\u8bc4\u4f30\u6bcf\u4e2a\u5c0f\u65f6\u6bb5\u5bf9\u5e94\u7684\u5355\u4f4d\u6548\u679c\n \u5e94\u8be5\u91c7\u7528\u8be5\u65f6\u6bb5\u7684\u5e73\u5747\u9605\u8bfb\u91cf=\u9605\u8bfb\u603b\u91cf\/\u53d1\u6587\u6570\u91cf\n \u5efa\u8bae\u4f7f\u7528\u6761\u5f62\u56fe\u5c55\u793a","docstring_summary":"\u4e00\u5929\u4e2d\u7684\u4e0d\u540c\u5c0f\u65f6\u6bb5\u53d1\u6587\u6570\u91cf\u5e76\u4e0d\u76f8\u540c,\u4ec5\u4ec5\u6bd4\u8f83\u53d1\u6587\u603b\u6570,\u548c\u603b\u9605\u8bfb\u91cf\u65e0\u6cd5\u8bc4\u4f30\u6bcf\u4e2a\u5c0f\u65f6\u6bb5\u5bf9\u5e94\u7684\u5355\u4f4d\u6548\u679c\n \u5e94\u8be5\u91c7\u7528\u8be5\u65f6\u6bb5\u7684\u5e73\u5747\u9605\u8bfb\u91cf=\u9605\u8bfb\u603b\u91cf\/\u53d1\u6587\u6570\u91cf\n \u5efa\u8bae\u4f7f\u7528\u6761\u5f62\u56fe\u5c55\u793a","docstring_tokens":["\u4e00\u5929\u4e2d\u7684\u4e0d\u540c\u5c0f\u65f6\u6bb5\u53d1\u6587\u6570\u91cf\u5e76\u4e0d\u76f8\u540c","\u4ec5\u4ec5\u6bd4\u8f83\u53d1\u6587\u603b\u6570","\u548c\u603b\u9605\u8bfb\u91cf\u65e0\u6cd5\u8bc4\u4f30\u6bcf\u4e2a\u5c0f\u65f6\u6bb5\u5bf9\u5e94\u7684\u5355\u4f4d\u6548\u679c","\u5e94\u8be5\u91c7\u7528\u8be5\u65f6\u6bb5\u7684\u5e73\u5747\u9605\u8bfb\u91cf","=","\u9605\u8bfb\u603b\u91cf","\/","\u53d1\u6587\u6570\u91cf","\u5efa\u8bae\u4f7f\u7528\u6761\u5f62\u56fe\u5c55\u793a"],"function":"def averageHourRead(self):\n '''\n \u4e00\u5929\u4e2d\u7684\u4e0d\u540c\u5c0f\u65f6\u6bb5\u53d1\u6587\u6570\u91cf\u5e76\u4e0d\u76f8\u540c,\u4ec5\u4ec5\u6bd4\u8f83\u53d1\u6587\u603b\u6570,\u548c\u603b\u9605\u8bfb\u91cf\u65e0\u6cd5\u8bc4\u4f30\u6bcf\u4e2a\u5c0f\u65f6\u6bb5\u5bf9\u5e94\u7684\u5355\u4f4d\u6548\u679c\n \u5e94\u8be5\u91c7\u7528\u8be5\u65f6\u6bb5\u7684\u5e73\u5747\u9605\u8bfb\u91cf=\u9605\u8bfb\u603b\u91cf\/\u53d1\u6587\u6570\u91cf\n \u5efa\u8bae\u4f7f\u7528\u6761\u5f62\u56fe\u5c55\u793a\n '''\n return self.posts_df.groupby('hour').describe(percentiles=[.5])['read']","function_tokens":["def","averageHourRead","(","self",")",":","return","self",".","posts_df",".","groupby","(","'hour'",")",".","describe","(","percentiles","=","[",".5","]",")","[","'read'","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L103-L109"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.getNumN","parameters":"(self,com='read',n=10, asc=0, mov='main')","argument_list":"","return_statement":"return df2.loc[df2.index[0:n]]","docstring":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_summary":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_tokens":["\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c"],"function":"def getNumN(self,com='read',n=10, asc=0, mov='main'):\n '''\n \u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c\n '''\n if com == 'fall_index':\n df = self.allMainDateRead()\n else:\n df = self.posts_df\n if mov=='main' and com!='fall_index':df = df.loc[df['mov']==10]\n # \u6309\u7167\u9605\u8bfb\u91cf\u8fdb\u884c\u964d\u5e8f\u6392\u5e8f\n df2 = df.sort_values([com],ascending=asc)\n return df2.loc[df2.index[0:n]]","function_tokens":["def","getNumN","(","self",",","com","=","'read'",",","n","=","10",",","asc","=","0",",","mov","=","'main'",")",":","if","com","==","'fall_index'",":","df","=","self",".","allMainDateRead","(",")","else",":","df","=","self",".","posts_df","if","mov","==","'main'","and","com","!=","'fall_index'",":","df","=","df",".","loc","[","df","[","'mov'","]","==","10","]","# \u6309\u7167\u9605\u8bfb\u91cf\u8fdb\u884c\u964d\u5e8f\u6392\u5e8f","df2","=","df",".","sort_values","(","[","com","]",",","ascending","=","asc",")","return","df2",".","loc","[","df2",".","index","[","0",":","n","]","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L111-L122"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.getNumNExcept","parameters":"(self,com='read',exce=100001,n=10, asc=0, mov='main')","argument_list":"","return_statement":"return df2.loc[df2.index[0:n]]","docstring":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_summary":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_tokens":["\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c"],"function":"def getNumNExcept(self,com='read',exce=100001,n=10, asc=0, mov='main'):\n '''\n \u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c\n '''\n df = self.posts_df.loc[self.posts_df[com] != exce]\n if mov=='main':df = df.loc[df['mov']==10]\n # \u6309\u7167\u9605\u8bfb\u91cf\u8fdb\u884c\u964d\u5e8f\u6392\u5e8f\n df2 = df.sort_values([com],ascending=asc)\n return df2.loc[df2.index[0:n]]","function_tokens":["def","getNumNExcept","(","self",",","com","=","'read'",",","exce","=","100001",",","n","=","10",",","asc","=","0",",","mov","=","'main'",")",":","df","=","self",".","posts_df",".","loc","[","self",".","posts_df","[","com","]","!=","exce","]","if","mov","==","'main'",":","df","=","df",".","loc","[","df","[","'mov'","]","==","10","]","# \u6309\u7167\u9605\u8bfb\u91cf\u8fdb\u884c\u964d\u5e8f\u6392\u5e8f","df2","=","df",".","sort_values","(","[","com","]",",","ascending","=","asc",")","return","df2",".","loc","[","df2",".","index","[","0",":","n","]","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L124-L132"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.getNumCondition","parameters":"(self,com='read',thr=100001,dir='==', mov='main')","argument_list":"","return_statement":"","docstring":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_summary":"\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c","docstring_tokens":["\u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c"],"function":"def getNumCondition(self,com='read',thr=100001,dir='==', mov='main'):\n '''\n \u8fd4\u56de\u6307\u5b9a\u5b57\u6bb5\u6700\u9ad8\u6216\u6700\u4f4e\u7684n\u884c\n '''\n df = self.posts_df\n if mov=='main':df = df.loc[df['mov']==10]\n if dir=='!=':return df.loc[df[com] != thr]\n elif dir=='>=':return df.loc[df[com] >= thr]\n elif dir=='<=':return df.loc[df[com] <= thr]\n elif dir=='>':return df.loc[df[com] > thr]\n elif dir=='<':return df.loc[df[com] < thr]\n else:return df.loc[df[com] == thr]","function_tokens":["def","getNumCondition","(","self",",","com","=","'read'",",","thr","=","100001",",","dir","=","'=='",",","mov","=","'main'",")",":","df","=","self",".","posts_df","if","mov","==","'main'",":","df","=","df",".","loc","[","df","[","'mov'","]","==","10","]","if","dir","==","'!='",":","return","df",".","loc","[","df","[","com","]","!=","thr","]","elif","dir","==","'>='",":","return","df",".","loc","[","df","[","com","]",">=","thr","]","elif","dir","==","'<='",":","return","df",".","loc","[","df","[","com","]","<=","thr","]","elif","dir","==","'>'",":","return","df",".","loc","[","df","[","com","]",">","thr","]","elif","dir","==","'<'",":","return","df",".","loc","[","df","[","com","]","<","thr","]","else",":","return","df",".","loc","[","df","[","com","]","==","thr","]"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L134-L145"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/GZH.py","language":"python","identifier":"GZH.getRwaDatarame","parameters":"(self)","argument_list":"","return_statement":"return self.posts_df","docstring":"\u8fd4\u56de\u539f\u59cb\u7684\u6570\u636e\u96c6\u5408,\u81ea\u5df1\u7f16\u5199\u641c\u7d22\u89c4\u5219\n # \u67d0\u4e2a\u5c5e\u6027\u5305\u542b\u591a\u4e2a\u503c\u4e2d\u7684\u4e00\u4e2a\n df2.loc[df2['hour'].isin([21,20])]\n # \u591a\u4e2a\u6761\u4ef6\n df2.loc[(df2.hour==21) & (df2.read>=20000)]\n # \u6307\u5b9a\u9700\u8981\u8fd4\u56de\u7684collumes\n df2.loc[(df2.hour==21) & (df2.read>=20000),['like','hour']]","docstring_summary":"\u8fd4\u56de\u539f\u59cb\u7684\u6570\u636e\u96c6\u5408,\u81ea\u5df1\u7f16\u5199\u641c\u7d22\u89c4\u5219\n # \u67d0\u4e2a\u5c5e\u6027\u5305\u542b\u591a\u4e2a\u503c\u4e2d\u7684\u4e00\u4e2a\n df2.loc[df2['hour'].isin([21,20])]\n # \u591a\u4e2a\u6761\u4ef6\n df2.loc[(df2.hour==21) & (df2.read>=20000)]\n # \u6307\u5b9a\u9700\u8981\u8fd4\u56de\u7684collumes\n df2.loc[(df2.hour==21) & (df2.read>=20000),['like','hour']]","docstring_tokens":["\u8fd4\u56de\u539f\u59cb\u7684\u6570\u636e\u96c6\u5408","\u81ea\u5df1\u7f16\u5199\u641c\u7d22\u89c4\u5219","#","\u67d0\u4e2a\u5c5e\u6027\u5305\u542b\u591a\u4e2a\u503c\u4e2d\u7684\u4e00\u4e2a","df2",".","loc","[","df2","[","hour","]",".","isin","(","[","21","20","]",")","]","#","\u591a\u4e2a\u6761\u4ef6","df2",".","loc","[","(","df2",".","hour","==","21",")","&","(","df2",".","read",">","=","20000",")","]","#","\u6307\u5b9a\u9700\u8981\u8fd4\u56de\u7684collumes","df2",".","loc","[","(","df2",".","hour","==","21",")","&","(","df2",".","read",">","=","20000",")","[","like","hour","]]"],"function":"def getRwaDatarame(self):\n '''\n \u8fd4\u56de\u539f\u59cb\u7684\u6570\u636e\u96c6\u5408,\u81ea\u5df1\u7f16\u5199\u641c\u7d22\u89c4\u5219\n # \u67d0\u4e2a\u5c5e\u6027\u5305\u542b\u591a\u4e2a\u503c\u4e2d\u7684\u4e00\u4e2a\n df2.loc[df2['hour'].isin([21,20])]\n # \u591a\u4e2a\u6761\u4ef6\n df2.loc[(df2.hour==21) & (df2.read>=20000)]\n # \u6307\u5b9a\u9700\u8981\u8fd4\u56de\u7684collumes\n df2.loc[(df2.hour==21) & (df2.read>=20000),['like','hour']]\n '''\n return self.posts_df","function_tokens":["def","getRwaDatarame","(","self",")",":","return","self",".","posts_df"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/GZH.py#L147-L157"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/__init__.py","language":"python","identifier":"GZHReportData.__init__","parameters":"(self, nickname)","argument_list":"","return_statement":"","docstring":":param nickname: \u516c\u4f17\u53f7\u540d\u79f0","docstring_summary":":param nickname: \u516c\u4f17\u53f7\u540d\u79f0","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u540d\u79f0"],"function":"def __init__(self, nickname):\n \"\"\"\n :param nickname: \u516c\u4f17\u53f7\u540d\u79f0\n \"\"\"\n self.nickname = nickname\n # \u751f\u6210\u5668\u8f6c\u5316\u6210\u4e3alist \u8d4b\u503c\u7ed9self.posts\n self.posts = []\n self.total_num = 0\n self.crawled_num = 0\n self.uncrawled_num = 0\n for p in get_collection_article(nickname):\n # \u8fc7\u6ee4\u6389\u6ca1\u6709\u722c\u53d6\u9605\u8bfb\u6570\u636e\u7684\u6587\u7ae0\n if 'read_num' in p:\n self.posts.append(p)\n self.crawled_num += 1\n else:\n self.uncrawled_num += 1\n self.total_num += 1\n #\n if self.crawled_num != 0:\n self.gzh = GZH(self.posts)\n self.gzh.postsToDataframe()\n # echarts\u7684option_data\n self.option_data = {}\n # \u516c\u4f17\u53f7\u540d\u79f0\n self.option_data['account_name'] = nickname\n # \u7d2f\u8ba1\u53d1\u6587\u603b\u6570\n self.option_data['posts_info'] = ' \u6709\u6548\u6587\u7ae0%d \u5176\u4e2d%d\u5177\u6709\u9605\u8bfb\u6570\u636e \u8fd8\u5269%d\u5c1a\u65e0\u9605\u8bfb\u6570\u636e'%\\\n (self.total_num,self.crawled_num,self.uncrawled_num)","function_tokens":["def","__init__","(","self",",","nickname",")",":","self",".","nickname","=","nickname","# \u751f\u6210\u5668\u8f6c\u5316\u6210\u4e3alist \u8d4b\u503c\u7ed9self.posts","self",".","posts","=","[","]","self",".","total_num","=","0","self",".","crawled_num","=","0","self",".","uncrawled_num","=","0","for","p","in","get_collection_article","(","nickname",")",":","# \u8fc7\u6ee4\u6389\u6ca1\u6709\u722c\u53d6\u9605\u8bfb\u6570\u636e\u7684\u6587\u7ae0","if","'read_num'","in","p",":","self",".","posts",".","append","(","p",")","self",".","crawled_num","+=","1","else",":","self",".","uncrawled_num","+=","1","self",".","total_num","+=","1","#","if","self",".","crawled_num","!=","0",":","self",".","gzh","=","GZH","(","self",".","posts",")","self",".","gzh",".","postsToDataframe","(",")","# echarts\u7684option_data","self",".","option_data","=","{","}","# \u516c\u4f17\u53f7\u540d\u79f0","self",".","option_data","[","'account_name'","]","=","nickname","# \u7d2f\u8ba1\u53d1\u6587\u603b\u6570","self",".","option_data","[","'posts_info'","]","=","' \u6709\u6548\u6587\u7ae0%d \u5176\u4e2d%d\u5177\u6709\u9605\u8bfb\u6570\u636e \u8fd8\u5269%d\u5c1a\u65e0\u9605\u8bfb\u6570\u636e'%\\","","(","self",".","total_num",",","self",".","crawled_num",",","self",".","uncrawled_num",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/__init__.py#L12-L40"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/__init__.py","language":"python","identifier":"GZHReportData._add_option_data","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u5c06\u516c\u4f17\u53f7\u8868\u683c\u4e2d\u9700\u8981\u7684\u6570\u636e\u9010\u4e2a\u6dfb\u52a0\u5230self.option_data","docstring_summary":":return:\u5c06\u516c\u4f17\u53f7\u8868\u683c\u4e2d\u9700\u8981\u7684\u6570\u636e\u9010\u4e2a\u6dfb\u52a0\u5230self.option_data","docstring_tokens":[":","return",":","\u5c06\u516c\u4f17\u53f7\u8868\u683c\u4e2d\u9700\u8981\u7684\u6570\u636e\u9010\u4e2a\u6dfb\u52a0\u5230self",".","option_data"],"function":"def _add_option_data(self):\n \"\"\"\n :return:\u5c06\u516c\u4f17\u53f7\u8868\u683c\u4e2d\u9700\u8981\u7684\u6570\u636e\u9010\u4e2a\u6dfb\u52a0\u5230self.option_data\n \"\"\"\n # \u5386\u53f2\u6240\u6709\u6587\u7ae0\u9605\u8bfb\u6570\u636e\n df = self.gzh.allMainDateRead()\n all_mian_date_read = draw_all_mian_date_read(df)\n self.option_data['all_mian_date_read'] = all_mian_date_read\n\n # \u4e3b\u526f\u6587\u7ae0\u7edf\u8ba1\u6570\u636e\n df = self.gzh.allStatistic()\n all_statistic = draw_all_statistic(df)\n self.option_data['all_statistic'] = all_statistic\n\n # \u4e0d\u540c\u4e3b\u526f\/\u5c0f\u65f6\/\u661f\u671f\u7c7b\u522b\u6587\u7ae0\u53d1\u6587\u6570\u91cf\u7edf\u8ba1\n dfd = self.gzh.dirPostsNumRelated()\n dir_posts_num_related = draw_dir_posts_num_related(dfd)\n self.option_data['dir_posts_num_related'] = dir_posts_num_related\n\n # \u9605\u8bfb\u91cf\u5206\u522b\u548c\u70b9\u8d5e\u91cf\/\u4e0a\u4e00\u6b21\u9605\u8bfb\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\n df = self.gzh.factorsAndRead()\n self.option_data['read_vs_factors'] = draw_read_vs_factors(df)\n # \u63a2\u7d22\u6700\u4f73\u63a8\u6587\u5c0f\u65f6 \u63a8\u6587\u661f\u671f \u6807\u9898\u8bcd\u6570 \u63d2\u56fe\u6570\u91cf \u89c6\u9891\u6570\u91cf\n self.option_data['find_best_factors'] = draw_find_best_factors(df)\n\n # \u6587\u7ae0\u5217\u8868\u6570\u636e\n self.option_data['table'] = {}\n # \u88689 100001\u9664\u5916\u9605\u8bfb\u6765\u90a3\u4e2a\u6700\u9ad8\u768410\u7bc7\u6587\u7ae0\n df = self.gzh.getNumNExcept(mov='all')\n self.option_data['table']['particular_most_read_10_except_100001'] = df2table(df, ['like','\u70b9\u8d5e\u91cf'])\n # \u886810 \u9605\u8bfb\u91cf\u6700\u4f4e\u4e14\u4e3a\u975e0\u768410\u7bc7\u6587\u7ae0\n df = self.gzh.getNumNExcept(com='read', exce=0, asc=1)\n self.option_data['table']['particular_least_read_10_except_0'] = df2table(df, ['like','\u70b9\u8d5e\u91cf'])\n # \u886811 \u6df1\u5ea6\u6307\u6570\u6700\u9ad8\u768410\u7bc7\u6587\u7ae0.\n df = self.gzh.getNumN(com='deep_index')\n self.option_data['table']['particular_most_deep_10'] = df2table(df, ['deep_index','\u6df1\u5ea6\u6307\u6570'])\n # \u886812 \u6df1\u5ea6\u6307\u6570\u6700\u4f4e\u768410\u7bc7\u6587\u7ae0\n df = self.gzh.getNumN(com='deep_index', asc=1)\n self.option_data['table']['particular_least_deep_10'] = df2table(df, ['deep_index','\u6df1\u5ea6\u6307\u6570'])\n # \u886813 \u843d\u5dee\u6307\u6570\u6700\u4f4e\u768410\u7bc7\u6587\u7ae0\n df = self.gzh.getNumN(com='fall_index', asc=1)\n self.option_data['table']['particular_least_fall_10'] = df2table(df, ['fall_index','\u843d\u5dee\u6307\u6570'])\n # \u886814 \u6240\u6709\u7684100001\u6587\u7ae0\n df = self.gzh.getNumCondition(mov='all')\n self.option_data['table']['particular_all_10001'] = df2table(df, ['like','\u70b9\u8d5e\u91cf'])","function_tokens":["def","_add_option_data","(","self",")",":","# \u5386\u53f2\u6240\u6709\u6587\u7ae0\u9605\u8bfb\u6570\u636e","df","=","self",".","gzh",".","allMainDateRead","(",")","all_mian_date_read","=","draw_all_mian_date_read","(","df",")","self",".","option_data","[","'all_mian_date_read'","]","=","all_mian_date_read","# \u4e3b\u526f\u6587\u7ae0\u7edf\u8ba1\u6570\u636e","df","=","self",".","gzh",".","allStatistic","(",")","all_statistic","=","draw_all_statistic","(","df",")","self",".","option_data","[","'all_statistic'","]","=","all_statistic","# \u4e0d\u540c\u4e3b\u526f\/\u5c0f\u65f6\/\u661f\u671f\u7c7b\u522b\u6587\u7ae0\u53d1\u6587\u6570\u91cf\u7edf\u8ba1","dfd","=","self",".","gzh",".","dirPostsNumRelated","(",")","dir_posts_num_related","=","draw_dir_posts_num_related","(","dfd",")","self",".","option_data","[","'dir_posts_num_related'","]","=","dir_posts_num_related","# \u9605\u8bfb\u91cf\u5206\u522b\u548c\u70b9\u8d5e\u91cf\/\u4e0a\u4e00\u6b21\u9605\u8bfb\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb","df","=","self",".","gzh",".","factorsAndRead","(",")","self",".","option_data","[","'read_vs_factors'","]","=","draw_read_vs_factors","(","df",")","# \u63a2\u7d22\u6700\u4f73\u63a8\u6587\u5c0f\u65f6 \u63a8\u6587\u661f\u671f \u6807\u9898\u8bcd\u6570 \u63d2\u56fe\u6570\u91cf \u89c6\u9891\u6570\u91cf","self",".","option_data","[","'find_best_factors'","]","=","draw_find_best_factors","(","df",")","# \u6587\u7ae0\u5217\u8868\u6570\u636e","self",".","option_data","[","'table'","]","=","{","}","# \u88689 100001\u9664\u5916\u9605\u8bfb\u6765\u90a3\u4e2a\u6700\u9ad8\u768410\u7bc7\u6587\u7ae0","df","=","self",".","gzh",".","getNumNExcept","(","mov","=","'all'",")","self",".","option_data","[","'table'","]","[","'particular_most_read_10_except_100001'","]","=","df2table","(","df",",","[","'like'",",","'\u70b9\u8d5e\u91cf'])","","","# \u886810 \u9605\u8bfb\u91cf\u6700\u4f4e\u4e14\u4e3a\u975e0\u768410\u7bc7\u6587\u7ae0","df","=","self",".","gzh",".","getNumNExcept","(","com","=","'read'",",","exce","=","0",",","asc","=","1",")","self",".","option_data","[","'table'","]","[","'particular_least_read_10_except_0'","]","=","df2table","(","df",",","[","'like'",",","'\u70b9\u8d5e\u91cf'])","","","# \u886811 \u6df1\u5ea6\u6307\u6570\u6700\u9ad8\u768410\u7bc7\u6587\u7ae0.","df","=","self",".","gzh",".","getNumN","(","com","=","'deep_index'",")","self",".","option_data","[","'table'","]","[","'particular_most_deep_10'","]","=","df2table","(","df",",","[","'deep_index'",",","'\u6df1\u5ea6\u6307\u6570'])","","","# \u886812 \u6df1\u5ea6\u6307\u6570\u6700\u4f4e\u768410\u7bc7\u6587\u7ae0","df","=","self",".","gzh",".","getNumN","(","com","=","'deep_index'",",","asc","=","1",")","self",".","option_data","[","'table'","]","[","'particular_least_deep_10'","]","=","df2table","(","df",",","[","'deep_index'",",","'\u6df1\u5ea6\u6307\u6570'])","","","# \u886813 \u843d\u5dee\u6307\u6570\u6700\u4f4e\u768410\u7bc7\u6587\u7ae0","df","=","self",".","gzh",".","getNumN","(","com","=","'fall_index'",",","asc","=","1",")","self",".","option_data","[","'table'","]","[","'particular_least_fall_10'","]","=","df2table","(","df",",","[","'fall_index'",",","'\u843d\u5dee\u6307\u6570'])","","","# \u886814 \u6240\u6709\u7684100001\u6587\u7ae0","df","=","self",".","gzh",".","getNumCondition","(","mov","=","'all'",")","self",".","option_data","[","'table'","]","[","'particular_all_10001'","]","=","df2table","(","df",",","[","'like'",",","'\u70b9\u8d5e\u91cf'])","",""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/__init__.py#L42-L86"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/__init__.py","language":"python","identifier":"GZHReportData.create_js","parameters":"(self)","argument_list":"","return_statement":"return option_data_js,'auto_created_js\/'+js_name+'.js'","docstring":":param des_dir:\u4ea7\u751fjs\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e\n :return:js\u6587\u4ef6\u540d","docstring_summary":":param des_dir:\u4ea7\u751fjs\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e\n :return:js\u6587\u4ef6\u540d","docstring_tokens":[":","param","des_dir",":","\u4ea7\u751fjs\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e",":","return",":","js\u6587\u4ef6\u540d"],"function":"def create_js(self):\n \"\"\"\n :param des_dir:\u4ea7\u751fjs\u6587\u4ef6\u7684\u5b58\u50a8\u4f4d\u7f6e\n :return:js\u6587\u4ef6\u540d\n \"\"\"\n from time import time\n self._add_option_data()\n js_name = 'cache_'+str(time())\n js_file = r\"ui\/static\/auto_created_js\/\"+js_name+'.js'\n # \u6253\u5f00\u6a21\u677f\u6587\u4ef6\n with open(r'ui\/templates\/option_data.js','r',encoding='utf8') as f:\n template = Template(f.read())\n # \u4f7f\u7528self.option_data\u6e32\u67d3js\u6a21\u677f\u6587\u4ef6option_data.js\n option_data_js = template.render(data=self.option_data)\n # \u4fdd\u5b58\u6e32\u67d3\u540e\u7684option_data.js\n with open(js_file,'w',encoding='utf8') as f:\n f.writelines(option_data_js)\n return option_data_js,'auto_created_js\/'+js_name+'.js'","function_tokens":["def","create_js","(","self",")",":","from","time","import","time","self",".","_add_option_data","(",")","js_name","=","'cache_'","+","str","(","time","(",")",")","js_file","=","r\"ui\/static\/auto_created_js\/\"","+","js_name","+","'.js'","# \u6253\u5f00\u6a21\u677f\u6587\u4ef6","with","open","(","r'ui\/templates\/option_data.js'",",","'r'",",","encoding","=","'utf8'",")","as","f",":","template","=","Template","(","f",".","read","(",")",")","# \u4f7f\u7528self.option_data\u6e32\u67d3js\u6a21\u677f\u6587\u4ef6option_data.js","option_data_js","=","template",".","render","(","data","=","self",".","option_data",")","# \u4fdd\u5b58\u6e32\u67d3\u540e\u7684option_data.js","with","open","(","js_file",",","'w'",",","encoding","=","'utf8'",")","as","f",":","f",".","writelines","(","option_data_js",")","return","option_data_js",",","'auto_created_js\/'","+","js_name","+","'.js'"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/__init__.py#L88-L105"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/utils.py","language":"python","identifier":"df2table","parameters":"(df, attr)","argument_list":"","return_statement":"return table_data","docstring":"attr\u662f\u8868\u683c\u72ec\u81ea\u5217\u7684\u82f1\u6587\u540d\u79f0\u548c\u4e2d\u6587\u540d\u79f0,\u4f8b\u5982:['name','\u540d\u5b57']\n \u82f1\u6587\u540d\u79f0\u7528\u4e8e\u7d22\u5f15df \u4e2d\u6587\u540d\u79f0\u7528\u4e8e\u8868\u683c\u6807\u9898","docstring_summary":"attr\u662f\u8868\u683c\u72ec\u81ea\u5217\u7684\u82f1\u6587\u540d\u79f0\u548c\u4e2d\u6587\u540d\u79f0,\u4f8b\u5982:['name','\u540d\u5b57']\n \u82f1\u6587\u540d\u79f0\u7528\u4e8e\u7d22\u5f15df \u4e2d\u6587\u540d\u79f0\u7528\u4e8e\u8868\u683c\u6807\u9898","docstring_tokens":["attr\u662f\u8868\u683c\u72ec\u81ea\u5217\u7684\u82f1\u6587\u540d\u79f0\u548c\u4e2d\u6587\u540d\u79f0","\u4f8b\u5982",":","[","name","\u540d\u5b57","]","\u82f1\u6587\u540d\u79f0\u7528\u4e8e\u7d22\u5f15df","\u4e2d\u6587\u540d\u79f0\u7528\u4e8e\u8868\u683c\u6807\u9898"],"function":"def df2table(df, attr):\n '''\n attr\u662f\u8868\u683c\u72ec\u81ea\u5217\u7684\u82f1\u6587\u540d\u79f0\u548c\u4e2d\u6587\u540d\u79f0,\u4f8b\u5982:['name','\u540d\u5b57']\n \u82f1\u6587\u540d\u79f0\u7528\u4e8e\u7d22\u5f15df \u4e2d\u6587\u540d\u79f0\u7528\u4e8e\u8868\u683c\u6807\u9898\n '''\n table_data = {}\n table_data['attribute'] = attr[1]\n table_data['data'] = []\n id = 0\n for index,row in df.iterrows():\n id += 1\n data_content = {}\n data_content['id'] = id\n # \u4e4b\u6240\u4ee5\u8981\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53bb\u9664\u6807\u9898\u4e2d\u7684`\u662f\u56e0\u4e3a\u5728js\u6587\u4ef6\u4e2d\u5c06\u4f7f\u7528``\u8868\u793a\u591a\u884c\u5b57\u7b26\u4e32\n data_content['title_cnt'] = re.sub(r'`','',row.title_cnt)\n data_content['url'] = row.url\n data_content['read'] = row.read\n data_content['like'] = row.like\n data_content['date'] = row.date\n if attr[0]!='read' : data_content['attribute'] = row[attr[0]]\n if attr[0]!='like' : data_content['attribute'] = row[attr[0]]\n table_data['data'].append(data_content)\n return table_data","function_tokens":["def","df2table","(","df",",","attr",")",":","table_data","=","{","}","table_data","[","'attribute'","]","=","attr","[","1","]","table_data","[","'data'","]","=","[","]","id","=","0","for","index",",","row","in","df",".","iterrows","(",")",":","id","+=","1","data_content","=","{","}","data_content","[","'id'","]","=","id","# \u4e4b\u6240\u4ee5\u8981\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53bb\u9664\u6807\u9898\u4e2d\u7684`\u662f\u56e0\u4e3a\u5728js\u6587\u4ef6\u4e2d\u5c06\u4f7f\u7528``\u8868\u793a\u591a\u884c\u5b57\u7b26\u4e32","data_content","[","'title_cnt'","]","=","re",".","sub","(","r'`'",",","''",",","row",".","title_cnt",")","data_content","[","'url'","]","=","row",".","url","data_content","[","'read'","]","=","row",".","read","data_content","[","'like'","]","=","row",".","like","data_content","[","'date'","]","=","row",".","date","if","attr","[","0","]","!=","'read'",":","data_content","[","'attribute'","]","=","row","[","attr","[","0","]","]","if","attr","[","0","]","!=","'like'",":","data_content","[","'attribute'","]","=","row","[","attr","[","0","]","]","table_data","[","'data'","]",".","append","(","data_content",")","return","table_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/utils.py#L3-L25"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/report\/gzh_report\/view.py","language":"python","identifier":"draw_all_mian_date_read","parameters":"(df)","argument_list":"","return_statement":"return bar.get_echarts_options()","docstring":":param df:\n :return:\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e","docstring_summary":":param df:\n :return:\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e","docstring_tokens":[":","param","df",":",":","return",":","\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e"],"function":"def draw_all_mian_date_read(df):\n \"\"\"\n :param df:\n :return:\u6240\u6709\u4e3b\u6587\u7ae0\u7684\u9605\u8bfb\u6570\u636e\n \"\"\"\n bar = Bar('\u6240\u6709\u53d1\u6587\u5386\u53f2\u6570\u636e')\n bar.add('\u9605\u8bfb\u91cf', df['date'], df['read'], mark_line=[\"min\", \"max\", \"average\"], is_datazoom_show=True, datazoom_type='both')\n bar.add('\u70b9\u8d5e\u91cf', df['date'], df['like'], mark_line=[\"min\", \"max\", \"average\"], is_datazoom_show=True, datazoom_type='both')\n bar.add('\u8bc4\u8bba\u91cf', df['date'], df['comment'], mark_line=[\"min\", \"max\", \"average\"], is_datazoom_show=True, datazoom_type='both')\n bar.add('\u8d5e\u8d4f\u91cf', df['date'], df['reward'], mark_line=[\"min\", \"max\", \"average\"], is_datazoom_show=True, datazoom_type='both')\n bar.add('\u6df1\u5ea6\u6307\u6570', df['date'], df['deep_index'], mark_line=[\"min\", \"max\", \"average\"], is_datazoom_show=True, datazoom_type='both')\n return bar.get_echarts_options()","function_tokens":["def","draw_all_mian_date_read","(","df",")",":","bar","=","Bar","(","'\u6240\u6709\u53d1\u6587\u5386\u53f2\u6570\u636e')","","bar",".","add","(","'\u9605\u8bfb\u91cf', df['","d","te","'","], df[","'","r","ad","'","], mar","k","_","ine=[\"min","\"",","," \"max","\""," \"ave","r","ge\"], is_","d","a","azoom_show=True,"," ","data","z","om_type='both","'",")","","bar",".","add","(","'\u70b9\u8d5e\u91cf', df['","d","te","'","], df[","'","l","ke","'","], mar","k","_","ine=[\"min","\"",","," \"max","\""," \"ave","r","ge\"], is_","d","a","azoom_show=True,"," ","data","z","om_type='both","'",")","","bar",".","add","(","'\u8bc4\u8bba\u91cf', df['","d","te","'","], df[","'","c","mm","e","nt'], mar","k","_","ine=[\"min","\"",","," \"max","\""," \"ave","r","ge\"], is_","d","a","azoom_show=True,"," ","data","z","om_type='both","'",")","","bar",".","add","(","'\u8d5e\u8d4f\u91cf', df['","d","te","'","], df[","'","r","wa","r","d'], mar","k","_","ine=[\"min","\"",","," \"max","\""," \"ave","r","ge\"], is_","d","a","azoom_show=True,"," ","data","z","om_type='both","'",")","","bar",".","add","(","'\u6df1\u5ea6\u6307\u6570', df['da","t","']",","," df['d","e","e","_i","n","dex'], mark_","l","i","e=[\"min\","," ","\"","max\","," ","avera","g","\"], is_da","t","a","oom_show=True, d","a","tazo","o","_type='both')","","","","return","bar",".","get_echarts_options","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/report\/gzh_report\/view.py#L3-L14"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_category\/__init__.py","language":"python","identifier":"GZHCategory.get_all_cat_data","parameters":"(self)","argument_list":"","return_statement":"return category","docstring":":return:\u8fd4\u56de\u5f53\u524d\u7684\u6240\u6709\u5206\u7c7b\u6570\u636e, \u6e29\u548c\u524d\u7aef\u7684\u6570\u636e\u683c\u5f0f","docstring_summary":":return:\u8fd4\u56de\u5f53\u524d\u7684\u6240\u6709\u5206\u7c7b\u6570\u636e, \u6e29\u548c\u524d\u7aef\u7684\u6570\u636e\u683c\u5f0f","docstring_tokens":[":","return",":","\u8fd4\u56de\u5f53\u524d\u7684\u6240\u6709\u5206\u7c7b\u6570\u636e","\u6e29\u548c\u524d\u7aef\u7684\u6570\u636e\u683c\u5f0f"],"function":"def get_all_cat_data(self):\n \"\"\"\n :return:\u8fd4\u56de\u5f53\u524d\u7684\u6240\u6709\u5206\u7c7b\u6570\u636e, \u6e29\u548c\u524d\u7aef\u7684\u6570\u636e\u683c\u5f0f\n \"\"\"\n category = []\n # \u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u6240\u6709\u516c\u4f17\u53f7\u7684\u540d\u79f0\u4e3a\u6dfb\u52a0\u9009\u9879\u505a\u51c6\u5907\n gzh_list = list(get_article_metadata().keys())\n # \u83b7\u5f97\u5206\u7c7b\u540d\u79f0\u548c\u8be5\u5206\u7c7b\u4e0b\u7684\u6240\u6709\u516c\u4f17\u53f7\n queue = DBQ.get_queue_by_kv(queue_type=self.queue_type)\n for cat in queue:\n data = {}\n data['cat_name'] = cat['name']\n data['cat_members'] = []\n for mem in cat['queue']:\n data['cat_members'].append(mem['id'])\n # \u627e\u51fa\u4e0d\u5728\u5206\u7c7b\u4e2d\u7684\u516c\u4f17\u53f7\u4f5c\u4e3a\u5f85\u52a0\u5165\u9009\u9879\n # data['cat_available'] = [x for x in gzh_list if x not in data['cat_members']]\n data['cat_available'] = sub_list(gzh_list, data['cat_members'])\n category.append(data)\n return category","function_tokens":["def","get_all_cat_data","(","self",")",":","category","=","[","]","# \u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u6240\u6709\u516c\u4f17\u53f7\u7684\u540d\u79f0\u4e3a\u6dfb\u52a0\u9009\u9879\u505a\u51c6\u5907","gzh_list","=","list","(","get_article_metadata","(",")",".","keys","(",")",")","# \u83b7\u5f97\u5206\u7c7b\u540d\u79f0\u548c\u8be5\u5206\u7c7b\u4e0b\u7684\u6240\u6709\u516c\u4f17\u53f7","queue","=","DBQ",".","get_queue_by_kv","(","queue_type","=","self",".","queue_type",")","for","cat","in","queue",":","data","=","{","}","data","[","'cat_name'","]","=","cat","[","'name'","]","data","[","'cat_members'","]","=","[","]","for","mem","in","cat","[","'queue'","]",":","data","[","'cat_members'","]",".","append","(","mem","[","'id'","]",")","# \u627e\u51fa\u4e0d\u5728\u5206\u7c7b\u4e2d\u7684\u516c\u4f17\u53f7\u4f5c\u4e3a\u5f85\u52a0\u5165\u9009\u9879","# data['cat_available'] = [x for x in gzh_list if x not in data['cat_members']]","data","[","'cat_available'","]","=","sub_list","(","gzh_list",",","data","[","'cat_members'","]",")","category",".","append","(","data",")","return","category"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_category\/__init__.py#L13-L32"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_category\/__init__.py","language":"python","identifier":"GZHCategory.add_cat","parameters":"(self, cat_name)","argument_list":"","return_statement":"return self.get_all_cat_data()","docstring":":param cat_name:\u5206\u7c7b\u540d\u79f0\n :return: \u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b","docstring_summary":":param cat_name:\u5206\u7c7b\u540d\u79f0\n :return: \u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b","docstring_tokens":[":","param","cat_name",":","\u5206\u7c7b\u540d\u79f0",":","return",":","\u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b"],"function":"def add_cat(self, cat_name):\n \"\"\"\n :param cat_name:\u5206\u7c7b\u540d\u79f0\n :return: \u6dfb\u52a0\u4e00\u4e2a\u5206\u7c7b\n \"\"\"\n DBQ(cat_name,self.queue_type)\n return self.get_all_cat_data()","function_tokens":["def","add_cat","(","self",",","cat_name",")",":","DBQ","(","cat_name",",","self",".","queue_type",")","return","self",".","get_all_cat_data","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_category\/__init__.py#L34-L40"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_category\/__init__.py","language":"python","identifier":"GZHCategory.delete_cat","parameters":"(self, cat_name)","argument_list":"","return_statement":"return self.get_all_cat_data()","docstring":":param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u5220\u9664\u4e00\u4e2a\u5206\u7c7b","docstring_summary":":param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u5220\u9664\u4e00\u4e2a\u5206\u7c7b","docstring_tokens":[":","param","cat_name",":","\u5206\u7c7b\u540d\u79f0",":","return",":","\u5220\u9664\u4e00\u4e2a\u5206\u7c7b"],"function":"def delete_cat(self, cat_name):\n \"\"\"\n :param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u5220\u9664\u4e00\u4e2a\u5206\u7c7b\n \"\"\"\n DBQ.delete_queue(cat_name,self.queue_type)\n return self.get_all_cat_data()","function_tokens":["def","delete_cat","(","self",",","cat_name",")",":","DBQ",".","delete_queue","(","cat_name",",","self",".","queue_type",")","return","self",".","get_all_cat_data","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_category\/__init__.py#L42-L48"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_category\/__init__.py","language":"python","identifier":"GZHCategory.add_cat_gzh","parameters":"(self, nickname, cat_name)","argument_list":"","return_statement":"return self.get_all_cat_data()","docstring":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name:\u5206\u7c7b\u540d\u79f0\n :return:\u5728\u6307\u5b9a\u5206\u7c7b\u4e2d\u589e\u52a0\u4e00\u4e2a\u516c\u4f17\u53f7","docstring_summary":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name:\u5206\u7c7b\u540d\u79f0\n :return:\u5728\u6307\u5b9a\u5206\u7c7b\u4e2d\u589e\u52a0\u4e00\u4e2a\u516c\u4f17\u53f7","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","param","cat_name",":","\u5206\u7c7b\u540d\u79f0",":","return",":","\u5728\u6307\u5b9a\u5206\u7c7b\u4e2d\u589e\u52a0\u4e00\u4e2a\u516c\u4f17\u53f7"],"function":"def add_cat_gzh(self, nickname, cat_name):\n \"\"\"\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name:\u5206\u7c7b\u540d\u79f0\n :return:\u5728\u6307\u5b9a\u5206\u7c7b\u4e2d\u589e\u52a0\u4e00\u4e2a\u516c\u4f17\u53f7\n \"\"\"\n cat = DBQ(name=cat_name,queue_type=self.queue_type)\n cat.add_element({'id':nickname})\n return self.get_all_cat_data()","function_tokens":["def","add_cat_gzh","(","self",",","nickname",",","cat_name",")",":","cat","=","DBQ","(","name","=","cat_name",",","queue_type","=","self",".","queue_type",")","cat",".","add_element","(","{","'id'",":","nickname","}",")","return","self",".","get_all_cat_data","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_category\/__init__.py#L50-L58"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_category\/__init__.py","language":"python","identifier":"GZHCategory.delete_cat_gzh","parameters":"(self, nickname, cat_name)","argument_list":"","return_statement":"return self.get_all_cat_data()","docstring":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u4ece\u6307\u5b9a\u5206\u7c7b\u4e2d\u5220\u9664\u4e00\u4e2a\u516c\u4f17\u53f7","docstring_summary":":param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u4ece\u6307\u5b9a\u5206\u7c7b\u4e2d\u5220\u9664\u4e00\u4e2a\u516c\u4f17\u53f7","docstring_tokens":[":","param","nickname",":","\u516c\u4f17\u53f7\u6635\u79f0",":","param","cat_name",":","\u5206\u7c7b\u540d\u79f0",":","return",":","\u4ece\u6307\u5b9a\u5206\u7c7b\u4e2d\u5220\u9664\u4e00\u4e2a\u516c\u4f17\u53f7"],"function":"def delete_cat_gzh(self, nickname, cat_name):\n \"\"\"\n :param nickname:\u516c\u4f17\u53f7\u6635\u79f0\n :param cat_name: \u5206\u7c7b\u540d\u79f0\n :return:\u4ece\u6307\u5b9a\u5206\u7c7b\u4e2d\u5220\u9664\u4e00\u4e2a\u516c\u4f17\u53f7\n \"\"\"\n cat = DBQ(name=cat_name,queue_type=self.queue_type)\n cat.delete_element({'id':nickname})\n return self.get_all_cat_data()","function_tokens":["def","delete_cat_gzh","(","self",",","nickname",",","cat_name",")",":","cat","=","DBQ","(","name","=","cat_name",",","queue_type","=","self",".","queue_type",")","cat",".","delete_element","(","{","'id'",":","nickname","}",")","return","self",".","get_all_cat_data","(",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_category\/__init__.py#L60-L68"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.report_gzh_finished","parameters":"(self)","argument_list":"","return_statement":"return report","docstring":":return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6240\u6709\u516c\u4f17\u53f7\u7684\u72b6\u6001 \u540d\u79f0 \u66f4\u65b0\u65f6\u95f4 \u7b49\u4fe1\u606f\n [{nickname,article_num,update_time,update_num}{}{}]\n report\u4e00\u6b21\u9700\u8981\u5355\u72ec\u8ba1\u7b97\u673a\u6bcf\u4e00\u4e2acollection\u4e2d\u7684\u6587\u6863\u6570\u91cf \u4f18\u79c0\u6d6a\u8d39\u65f6\u95f4 \u65b9\u6cd5\u5f85\u6539\u8fdb","docstring_summary":":return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6240\u6709\u516c\u4f17\u53f7\u7684\u72b6\u6001 \u540d\u79f0 \u66f4\u65b0\u65f6\u95f4 \u7b49\u4fe1\u606f\n [{nickname,article_num,update_time,update_num}{}{}]\n report\u4e00\u6b21\u9700\u8981\u5355\u72ec\u8ba1\u7b97\u673a\u6bcf\u4e00\u4e2acollection\u4e2d\u7684\u6587\u6863\u6570\u91cf \u4f18\u79c0\u6d6a\u8d39\u65f6\u95f4 \u65b9\u6cd5\u5f85\u6539\u8fdb","docstring_tokens":[":","return",":","\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6240\u6709\u516c\u4f17\u53f7\u7684\u72b6\u6001","\u540d\u79f0","\u66f4\u65b0\u65f6\u95f4","\u7b49\u4fe1\u606f","[","{","nickname","article_num","update_time","update_num","}","{}","{}","]","report\u4e00\u6b21\u9700\u8981\u5355\u72ec\u8ba1\u7b97\u673a\u6bcf\u4e00\u4e2acollection\u4e2d\u7684\u6587\u6863\u6570\u91cf","\u4f18\u79c0\u6d6a\u8d39\u65f6\u95f4","\u65b9\u6cd5\u5f85\u6539\u8fdb"],"function":"def report_gzh_finished(self):\n \"\"\"\n :return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6240\u6709\u516c\u4f17\u53f7\u7684\u72b6\u6001 \u540d\u79f0 \u66f4\u65b0\u65f6\u95f4 \u7b49\u4fe1\u606f\n [{nickname,article_num,update_time,update_num}{}{}]\n report\u4e00\u6b21\u9700\u8981\u5355\u72ec\u8ba1\u7b97\u673a\u6bcf\u4e00\u4e2acollection\u4e2d\u7684\u6587\u6863\u6570\u91cf \u4f18\u79c0\u6d6a\u8d39\u65f6\u95f4 \u65b9\u6cd5\u5f85\u6539\u8fdb\n \"\"\"\n # \u83b7\u53d6mongdb\u4e2d\u7684\u516c\u4f17\u53f7\u7684\u72b6\u6001\n report = {}\n report_data = []\n from db.meta_data import get_article_metadata\n from db import count\n meta_data = get_article_metadata(all=False)\n total_article = 0\n for key in meta_data:\n unit = {}\n unit['nickname'] = key\n unit['article_num'] = count(key)\n unit['update_time'] = meta_data[key]['date'].strftime(\"%Y\/%m\/%d %H:%M\")\n unit['update_num'] = meta_data[key]['articles_num']\n report_data.append(unit)\n total_article += unit['article_num']\n report['data'] = report_data\n report['meta'] = {}\n report['meta']['total_gzh'] = len(report_data)\n report['meta']['total_article'] = total_article\n return report","function_tokens":["def","report_gzh_finished","(","self",")",":","# \u83b7\u53d6mongdb\u4e2d\u7684\u516c\u4f17\u53f7\u7684\u72b6\u6001","report","=","{","}","report_data","=","[","]","from","db",".","meta_data","import","get_article_metadata","from","db","import","count","meta_data","=","get_article_metadata","(","all","=","False",")","total_article","=","0","for","key","in","meta_data",":","unit","=","{","}","unit","[","'nickname'","]","=","key","unit","[","'article_num'","]","=","count","(","key",")","unit","[","'update_time'","]","=","meta_data","[","key","]","[","'date'","]",".","strftime","(","\"%Y\/%m\/%d %H:%M\"",")","unit","[","'update_num'","]","=","meta_data","[","key","]","[","'articles_num'","]","report_data",".","append","(","unit",")","total_article","+=","unit","[","'article_num'","]","report","[","'data'","]","=","report_data","report","[","'meta'","]","=","{","}","report","[","'meta'","]","[","'total_gzh'","]","=","len","(","report_data",")","report","[","'meta'","]","[","'total_article'","]","=","total_article","return","report"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L19-L44"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler._report_gzh_doing","parameters":"(self)","argument_list":"","return_statement":"return report_data","docstring":":return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6b63\u5728\u8fdb\u884c\u4efb\u52a1\u7684\u516c\u4f17\u53f7\u72b6\u6001\n \u6570\u636e\u6765\u81ea\u4efb\u52a1\u961f\u5217 \u4efb\u52a1\u961f\u5217\u4e2d\u5b58\u5728\u7684\u516c\u4f17\u53f7\u548c\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u516c\u4f17\u53f7\n nickname,percent,begin_time,need_time","docstring_summary":":return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6b63\u5728\u8fdb\u884c\u4efb\u52a1\u7684\u516c\u4f17\u53f7\u72b6\u6001\n \u6570\u636e\u6765\u81ea\u4efb\u52a1\u961f\u5217 \u4efb\u52a1\u961f\u5217\u4e2d\u5b58\u5728\u7684\u516c\u4f17\u53f7\u548c\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u516c\u4f17\u53f7\n nickname,percent,begin_time,need_time","docstring_tokens":[":","return",":","\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6b63\u5728\u8fdb\u884c\u4efb\u52a1\u7684\u516c\u4f17\u53f7\u72b6\u6001","\u6570\u636e\u6765\u81ea\u4efb\u52a1\u961f\u5217","\u4efb\u52a1\u961f\u5217\u4e2d\u5b58\u5728\u7684\u516c\u4f17\u53f7\u548c\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u516c\u4f17\u53f7","nickname","percent","begin_time","need_time"],"function":"def _report_gzh_doing(self):\n \"\"\"\n :return:\u4ea7\u751f\u6570\u636e\u62a5\u544a\u6b63\u5728\u8fdb\u884c\u4efb\u52a1\u7684\u516c\u4f17\u53f7\u72b6\u6001\n \u6570\u636e\u6765\u81ea\u4efb\u52a1\u961f\u5217 \u4efb\u52a1\u961f\u5217\u4e2d\u5b58\u5728\u7684\u516c\u4f17\u53f7\u548c\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u516c\u4f17\u53f7\n nickname,percent,begin_time,need_time\n \"\"\"\n report_data = []\n from tools.utils import dictstr_to_dict\n # \u961f\u5217\u4e2d\u9700\u8981\u5904\u7406\u7684\u516c\u4f17\u53f7\n gzh_need_todolist = self.gzh_task_rq.get_rq_data()\n for gzh in gzh_need_todolist:\n gzh_task = dictstr_to_dict(gzh)\n unit = {}\n unit['nickname'] = gzh_task['nickname']\n unit['percent'] = 'UNK\/UNK'\n unit['begin_time'] = 'UNK'\n unit['need_time'] = 'UNK'\n report_data.append(unit)\n return report_data","function_tokens":["def","_report_gzh_doing","(","self",")",":","report_data","=","[","]","from","tools",".","utils","import","dictstr_to_dict","# \u961f\u5217\u4e2d\u9700\u8981\u5904\u7406\u7684\u516c\u4f17\u53f7","gzh_need_todolist","=","self",".","gzh_task_rq",".","get_rq_data","(",")","for","gzh","in","gzh_need_todolist",":","gzh_task","=","dictstr_to_dict","(","gzh",")","unit","=","{","}","unit","[","'nickname'","]","=","gzh_task","[","'nickname'","]","unit","[","'percent'","]","=","'UNK\/UNK'","unit","[","'begin_time'","]","=","'UNK'","unit","[","'need_time'","]","=","'UNK'","report_data",".","append","(","unit",")","return","report_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L46-L64"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.report_gzh_doing","parameters":"(self)","argument_list":"","return_statement":"return report_data","docstring":":return:\u5f53\u524d\u53ef\u80fd\u5e76\u672a\u4efb\u52a1","docstring_summary":":return:\u5f53\u524d\u53ef\u80fd\u5e76\u672a\u4efb\u52a1","docstring_tokens":[":","return",":","\u5f53\u524d\u53ef\u80fd\u5e76\u672a\u4efb\u52a1"],"function":"def report_gzh_doing(self):\n \"\"\"\n :return:\u5f53\u524d\u53ef\u80fd\u5e76\u672a\u4efb\u52a1\n \"\"\"\n try:\n report_data = self._report_gzh_doing()\n except:\n report_data = []\n return report_data","function_tokens":["def","report_gzh_doing","(","self",")",":","try",":","report_data","=","self",".","_report_gzh_doing","(",")","except",":","report_data","=","[","]","return","report_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L77-L85"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.add_crawler","parameters":"(self,crawler)","argument_list":"","return_statement":"","docstring":":param self:\n :return:\u6dfb\u52a0\u722c\u866b","docstring_summary":":param self:\n :return:\u6dfb\u52a0\u722c\u866b","docstring_tokens":[":","param","self",":",":","return",":","\u6dfb\u52a0\u722c\u866b"],"function":"def add_crawler(self,crawler):\n \"\"\"\n :param self:\n :return:\u6dfb\u52a0\u722c\u866b\n \"\"\"\n self.phone_adb_dbq.add_element({'id':crawler['phone'],'nick_name':'\u672a\u77e5','wxuin':'\u672a\u77e5'})","function_tokens":["def","add_crawler","(","self",",","crawler",")",":","self",".","phone_adb_dbq",".","add_element","(","{","'id'",":","crawler","[","'phone'","]",",","'nick_name'",":","'\u672a\u77e5','wx","u","in':'\u672a\u77e5","'","})","",""],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L87-L92"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.delete_crawler","parameters":"(self,crawler)","argument_list":"","return_statement":"","docstring":":param crawler:\n :return:\u5220\u9664\u722c\u866b","docstring_summary":":param crawler:\n :return:\u5220\u9664\u722c\u866b","docstring_tokens":[":","param","crawler",":",":","return",":","\u5220\u9664\u722c\u866b"],"function":"def delete_crawler(self,crawler):\n \"\"\"\n :param crawler:\n :return:\u5220\u9664\u722c\u866b\n \"\"\"\n print(crawler)\n self.phone_adb_dbq.delete_element({'id':crawler['phone']})","function_tokens":["def","delete_crawler","(","self",",","crawler",")",":","print","(","crawler",")","self",".","phone_adb_dbq",".","delete_element","(","{","'id'",":","crawler","[","'phone'","]","}",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L94-L100"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.report_crawling","parameters":"(self,item,num=15)","argument_list":"","return_statement":"return self.report_crawling_items","docstring":":param num: \u65e5\u5fd7\u6761\u6570\n :param item:{'nickname':**,'percent':'12\/1231','speed':0.023,'title':'***'}\n :return:","docstring_summary":":param num: \u65e5\u5fd7\u6761\u6570\n :param item:{'nickname':**,'percent':'12\/1231','speed':0.023,'title':'***'}\n :return:","docstring_tokens":[":","param","num",":","\u65e5\u5fd7\u6761\u6570",":","param","item",":","{","nickname",":","**","percent",":","12","\/","1231","speed",":","0",".","023","title",":","***","}",":","return",":"],"function":"def report_crawling(self,item,num=15):\n \"\"\"\n :param num: \u65e5\u5fd7\u6761\u6570\n :param item:{'nickname':**,'percent':'12\/1231','speed':0.023,'title':'***'}\n :return:\n \"\"\"\n from ui.ui_instance import socketio\n self.report_crawling_items = [item] + self.report_crawling_items\n if len(self.report_crawling_items)>num:\n self.report_crawling_items.pop()\n socketio.emit('articles_logger_monitoring',self.report_crawling_items)\n return self.report_crawling_items","function_tokens":["def","report_crawling","(","self",",","item",",","num","=","15",")",":","from","ui",".","ui_instance","import","socketio","self",".","report_crawling_items","=","[","item","]","+","self",".","report_crawling_items","if","len","(","self",".","report_crawling_items",")",">","num",":","self",".","report_crawling_items",".","pop","(",")","socketio",".","emit","(","'articles_logger_monitoring'",",","self",".","report_crawling_items",")","return","self",".","report_crawling_items"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L102-L113"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.add_gzh","parameters":"(self,gzh)","argument_list":"","return_statement":"","docstring":":param gzh:\n :return:\u6dfb\u52a0\u516c\u4f17\u53f7 \u5230\u4efb\u52a1\u961f\u5217","docstring_summary":":param gzh:\n :return:\u6dfb\u52a0\u516c\u4f17\u53f7 \u5230\u4efb\u52a1\u961f\u5217","docstring_tokens":[":","param","gzh",":",":","return",":","\u6dfb\u52a0\u516c\u4f17\u53f7","\u5230\u4efb\u52a1\u961f\u5217"],"function":"def add_gzh(self,gzh):\n \"\"\"\n :param gzh:\n :return:\u6dfb\u52a0\u516c\u4f17\u53f7 \u5230\u4efb\u52a1\u961f\u5217\n \"\"\"\n self.gzh_task_rq.push(gzh)","function_tokens":["def","add_gzh","(","self",",","gzh",")",":","self",".","gzh_task_rq",".","push","(","gzh",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L116-L121"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.delete_gzh","parameters":"(self,gzh)","argument_list":"","return_statement":"","docstring":":param gzh:\n :return:\u5220\u9664\u516c\u4f17\u53f7","docstring_summary":":param gzh:\n :return:\u5220\u9664\u516c\u4f17\u53f7","docstring_tokens":[":","param","gzh",":",":","return",":","\u5220\u9664\u516c\u4f17\u53f7"],"function":"def delete_gzh(self,gzh):\n \"\"\"\n :param gzh:\n :return:\u5220\u9664\u516c\u4f17\u53f7\n \"\"\"\n pass","function_tokens":["def","delete_gzh","(","self",",","gzh",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L123-L128"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.update_gzh","parameters":"(self,gzh,n)","argument_list":"","return_statement":"","docstring":":param gzh:\n :return: \u66f4\u65b0\u516c\u4f17\u53f7\u6587\u7ae0","docstring_summary":":param gzh:\n :return: \u66f4\u65b0\u516c\u4f17\u53f7\u6587\u7ae0","docstring_tokens":[":","param","gzh",":",":","return",":","\u66f4\u65b0\u516c\u4f17\u53f7\u6587\u7ae0"],"function":"def update_gzh(self,gzh,n):\n \"\"\"\n :param gzh:\n :return: \u66f4\u65b0\u516c\u4f17\u53f7\u6587\u7ae0\n \"\"\"\n pass","function_tokens":["def","update_gzh","(","self",",","gzh",",","n",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L130-L135"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.gzh_report","parameters":"(self,gzh)","argument_list":"","return_statement":"","docstring":":param gzh:\n :return:\u751f\u6210\u516c\u4f17\u53f7\u5386\u53f2\u6587\u7ae0\u6570\u636e\u62a5\u544a","docstring_summary":":param gzh:\n :return:\u751f\u6210\u516c\u4f17\u53f7\u5386\u53f2\u6587\u7ae0\u6570\u636e\u62a5\u544a","docstring_tokens":[":","param","gzh",":",":","return",":","\u751f\u6210\u516c\u4f17\u53f7\u5386\u53f2\u6587\u7ae0\u6570\u636e\u62a5\u544a"],"function":"def gzh_report(self,gzh):\n \"\"\"\n :param gzh:\n :return:\u751f\u6210\u516c\u4f17\u53f7\u5386\u53f2\u6587\u7ae0\u6570\u636e\u62a5\u544a\n \"\"\"\n pass","function_tokens":["def","gzh_report","(","self",",","gzh",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L137-L142"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.gzh_article_list","parameters":"(self,gzh)","argument_list":"","return_statement":"","docstring":":param gzh:\n :return: \u751f\u6210\u516c\u4f17\u53f7\u7684\u6240\u6709\u6587\u7ae0\u5217\u8868","docstring_summary":":param gzh:\n :return: \u751f\u6210\u516c\u4f17\u53f7\u7684\u6240\u6709\u6587\u7ae0\u5217\u8868","docstring_tokens":[":","param","gzh",":",":","return",":","\u751f\u6210\u516c\u4f17\u53f7\u7684\u6240\u6709\u6587\u7ae0\u5217\u8868"],"function":"def gzh_article_list(self,gzh):\n \"\"\"\n :param gzh:\n :return: \u751f\u6210\u516c\u4f17\u53f7\u7684\u6240\u6709\u6587\u7ae0\u5217\u8868\n \"\"\"\n pass","function_tokens":["def","gzh_article_list","(","self",",","gzh",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L144-L149"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.export_excel","parameters":"(self,gzh,field)","argument_list":"","return_statement":"","docstring":":param gzh:\n :param field:\n :return:\u516c\u4f17\u53f7\u7684\u6307\u5b9a\u5b57\u6bb5\u5230\u5904\u5230excel","docstring_summary":":param gzh:\n :param field:\n :return:\u516c\u4f17\u53f7\u7684\u6307\u5b9a\u5b57\u6bb5\u5230\u5904\u5230excel","docstring_tokens":[":","param","gzh",":",":","param","field",":",":","return",":","\u516c\u4f17\u53f7\u7684\u6307\u5b9a\u5b57\u6bb5\u5230\u5904\u5230excel"],"function":"def export_excel(self,gzh,field):\n \"\"\"\n :param gzh:\n :param field:\n :return:\u516c\u4f17\u53f7\u7684\u6307\u5b9a\u5b57\u6bb5\u5230\u5904\u5230excel\n \"\"\"\n pass","function_tokens":["def","export_excel","(","self",",","gzh",",","field",")",":","pass"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L151-L157"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/Application\/gzh_crawler\/__init__.py","language":"python","identifier":"GZHCrawler.run","parameters":"(self)","argument_list":"","return_statement":"","docstring":":return:\u65b0\u52a0\u5165\u7684\u722c\u866b\u6bcf\u5f53\u63a5\u5230\u6587\u7ae0\u722c\u53d6\u4efb\u65f6\u5c31\u4f1a\u81ea\u52a8\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570\n \u516c\u4f17\u53f7\u722c\u866b\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u76d1\u63a7\u516c\u4f17\u7684\u7684\u722c\u53d6\u4efb\u52a1\u548c\u66f4\u65b0\u4efb\u52a1\n run\u9700\u8981\u5728\u4e00\u4e2a\u8fdb\u7a0b\u4e2d\u4e0d\u505c\u6267\u884c","docstring_summary":":return:\u65b0\u52a0\u5165\u7684\u722c\u866b\u6bcf\u5f53\u63a5\u5230\u6587\u7ae0\u722c\u53d6\u4efb\u65f6\u5c31\u4f1a\u81ea\u52a8\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570\n \u516c\u4f17\u53f7\u722c\u866b\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u76d1\u63a7\u516c\u4f17\u7684\u7684\u722c\u53d6\u4efb\u52a1\u548c\u66f4\u65b0\u4efb\u52a1\n run\u9700\u8981\u5728\u4e00\u4e2a\u8fdb\u7a0b\u4e2d\u4e0d\u505c\u6267\u884c","docstring_tokens":[":","return",":","\u65b0\u52a0\u5165\u7684\u722c\u866b\u6bcf\u5f53\u63a5\u5230\u6587\u7ae0\u722c\u53d6\u4efb\u65f6\u5c31\u4f1a\u81ea\u52a8\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570","\u516c\u4f17\u53f7\u722c\u866b\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u76d1\u63a7\u516c\u4f17\u7684\u7684\u722c\u53d6\u4efb\u52a1\u548c\u66f4\u65b0\u4efb\u52a1","run\u9700\u8981\u5728\u4e00\u4e2a\u8fdb\u7a0b\u4e2d\u4e0d\u505c\u6267\u884c"],"function":"def run(self):\n \"\"\"\n :return:\u65b0\u52a0\u5165\u7684\u722c\u866b\u6bcf\u5f53\u63a5\u5230\u6587\u7ae0\u722c\u53d6\u4efb\u65f6\u5c31\u4f1a\u81ea\u52a8\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570\n \u516c\u4f17\u53f7\u722c\u866b\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\u76d1\u63a7\u516c\u4f17\u7684\u7684\u722c\u53d6\u4efb\u52a1\u548c\u66f4\u65b0\u4efb\u52a1\n run\u9700\u8981\u5728\u4e00\u4e2a\u8fdb\u7a0b\u4e2d\u4e0d\u505c\u6267\u884c\n \"\"\"\n # \u722c\u53d6\u4efb\u52a1\n from tools.utils import dictstr_to_dict\n gzh_task = self.gzh_task_rq.pop()\n if gzh_task == []:\n return\n gzh_task = dictstr_to_dict(gzh_task)\n self.gzh_in_service = gzh_task['nickname']\n print(gzh_task)\n # \u83b7\u53d6\u53c2\u6570\n adb_ports_raw = self.phone_adb_dbq.get_queue()\n adb_ports = []\n for adb in adb_ports_raw:\n adb_ports.append(adb['id'])\n wo = WeixinOperate(adb_ports)\n if gzh_task['aom'] == 'halfauto':\n wo.get_all_req_data(gzh_task['nickname'], hand=True)\n elif gzh_task['aom'] == 'auto':\n wo.get_all_req_data(gzh_task['nickname'], hand=False)\n # \u8c03\u7528\u722c\u866b\n from crawler import run_crawl\n config = int(gzh_task['range'])\n # from os import system\n # system('python run_crawler.py '+str(config))\n run_crawl(config)","function_tokens":["def","run","(","self",")",":","# \u722c\u53d6\u4efb\u52a1","from","tools",".","utils","import","dictstr_to_dict","gzh_task","=","self",".","gzh_task_rq",".","pop","(",")","if","gzh_task","==","[","]",":","return","gzh_task","=","dictstr_to_dict","(","gzh_task",")","self",".","gzh_in_service","=","gzh_task","[","'nickname'","]","print","(","gzh_task",")","# \u83b7\u53d6\u53c2\u6570","adb_ports_raw","=","self",".","phone_adb_dbq",".","get_queue","(",")","adb_ports","=","[","]","for","adb","in","adb_ports_raw",":","adb_ports",".","append","(","adb","[","'id'","]",")","wo","=","WeixinOperate","(","adb_ports",")","if","gzh_task","[","'aom'","]","==","'halfauto'",":","wo",".","get_all_req_data","(","gzh_task","[","'nickname'","]",",","hand","=","True",")","elif","gzh_task","[","'aom'","]","==","'auto'",":","wo",".","get_all_req_data","(","gzh_task","[","'nickname'","]",",","hand","=","False",")","# \u8c03\u7528\u722c\u866b","from","crawler","import","run_crawl","config","=","int","(","gzh_task","[","'range'","]",")","# from os import system","# system('python run_crawler.py '+str(config))","run_crawl","(","config",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/Application\/gzh_crawler\/__init__.py#L159-L188"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.get_all_req_data","parameters":"()","argument_list":"","return_statement":"return ordered_req_dict","docstring":"\u83b7\u53d6redis\u4e2d\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6\uff0c\u4e5f\u5c31\u662fkey\u4e2d\u542b\u6709.req\u5b57\u6bb5\u7684\u8bb0\u5f55\u3002\u6700\u7ec8\u8fd4\u56de\u7684\u6570\u636e\u6839\u636ekey\u4e2d\u7684\u65f6\u95f4\u6233\u8fdb\u884c\u6392\u5e8f\u8fc7\n :return:\n \uff5b'1532859863455.getappmsgext.req':dict_file,)\n '1523423421446.appmsg_comment.req':dict_file\uff5d","docstring_summary":"\u83b7\u53d6redis\u4e2d\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6\uff0c\u4e5f\u5c31\u662fkey\u4e2d\u542b\u6709.req\u5b57\u6bb5\u7684\u8bb0\u5f55\u3002\u6700\u7ec8\u8fd4\u56de\u7684\u6570\u636e\u6839\u636ekey\u4e2d\u7684\u65f6\u95f4\u6233\u8fdb\u884c\u6392\u5e8f\u8fc7\n :return:\n \uff5b'1532859863455.getappmsgext.req':dict_file,)\n '1523423421446.appmsg_comment.req':dict_file\uff5d","docstring_tokens":["\u83b7\u53d6redis\u4e2d\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6\uff0c\u4e5f\u5c31\u662fkey\u4e2d\u542b\u6709",".","req\u5b57\u6bb5\u7684\u8bb0\u5f55\u3002\u6700\u7ec8\u8fd4\u56de\u7684\u6570\u636e\u6839\u636ekey\u4e2d\u7684\u65f6\u95f4\u6233\u8fdb\u884c\u6392\u5e8f\u8fc7",":","return",":","\uff5b","1532859863455",".","getappmsgext",".","req",":","dict_file",")","1523423421446",".","appmsg_comment",".","req",":","dict_file\uff5d"],"function":"def get_all_req_data():\n \"\"\"\n \u83b7\u53d6redis\u4e2d\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6\uff0c\u4e5f\u5c31\u662fkey\u4e2d\u542b\u6709.req\u5b57\u6bb5\u7684\u8bb0\u5f55\u3002\u6700\u7ec8\u8fd4\u56de\u7684\u6570\u636e\u6839\u636ekey\u4e2d\u7684\u65f6\u95f4\u6233\u8fdb\u884c\u6392\u5e8f\u8fc7\n :return:\n \uff5b'1532859863455.getappmsgext.req':dict_file,)\n '1523423421446.appmsg_comment.req':dict_file\uff5d\n \"\"\"\n unordered_req_dict = {}\n ordered_req_dict = collections.OrderedDict()\n # \u904d\u5386\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6\n for key in redis_instance.keys(\"*.req\"):\n req_bin_data = redis_instance.get(key)\n try:\n req_dict_data = json.loads(req_bin_data)\n except:\n req_dict_data = str(req_bin_data)\n # req_dict_data = req_bin_data.decode('utf8')\n unordered_req_dict[key.decode('utf8')] = req_dict_data\n # \u6309\u7167\u65f6\u95f4\u987a\u5e8f\u6392\u5e8f\u4e4b\u540e\u8fd4\u56de\u5b57\u5178\n for key in sorted(unordered_req_dict.keys()):\n ordered_req_dict[key] = unordered_req_dict[key]\n return ordered_req_dict","function_tokens":["def","get_all_req_data","(",")",":","unordered_req_dict","=","{","}","ordered_req_dict","=","collections",".","OrderedDict","(",")","# \u904d\u5386\u6240\u6709\u7684\u8bf7\u6c42\u6587\u4ef6","for","key","in","redis_instance",".","keys","(","\"*.req\"",")",":","req_bin_data","=","redis_instance",".","get","(","key",")","try",":","req_dict_data","=","json",".","loads","(","req_bin_data",")","except",":","req_dict_data","=","str","(","req_bin_data",")","# req_dict_data = req_bin_data.decode('utf8')","unordered_req_dict","[","key",".","decode","(","'utf8'",")","]","=","req_dict_data","# \u6309\u7167\u65f6\u95f4\u987a\u5e8f\u6392\u5e8f\u4e4b\u540e\u8fd4\u56de\u5b57\u5178","for","key","in","sorted","(","unordered_req_dict",".","keys","(",")",")",":","ordered_req_dict","[","key","]","=","unordered_req_dict","[","key","]","return","ordered_req_dict"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L14-L35"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.add_nick_name","parameters":"(ordered_req_dict)","argument_list":"","return_statement":"return ordered_req_dict","docstring":":param ordered_req_dict:\n :return:\u6dfb\u52a0nick_name","docstring_summary":":param ordered_req_dict:\n :return:\u6dfb\u52a0nick_name","docstring_tokens":[":","param","ordered_req_dict",":",":","return",":","\u6dfb\u52a0nick_name"],"function":"def add_nick_name(ordered_req_dict):\n \"\"\"\n :param ordered_req_dict:\n :return:\u6dfb\u52a0nick_name\n \"\"\"\n wxuin_nn_dict = {}\n nickname = TidyReqData.get_nickname()\n for key in redis_instance.keys(\"*.nick_name\"):\n wxuin_nn_dict[(redis_instance.get(key)).decode('utf8')] = (key.decode('utf8')).split('.')[0]\n for key in ordered_req_dict:\n ordered_req_dict[key]['nick_name'] = wxuin_nn_dict[key]\n ordered_req_dict[key]['wxuin'] = key\n ordered_req_dict[key]['nickname'] = nickname\n return ordered_req_dict","function_tokens":["def","add_nick_name","(","ordered_req_dict",")",":","wxuin_nn_dict","=","{","}","nickname","=","TidyReqData",".","get_nickname","(",")","for","key","in","redis_instance",".","keys","(","\"*.nick_name\"",")",":","wxuin_nn_dict","[","(","redis_instance",".","get","(","key",")",")",".","decode","(","'utf8'",")","]","=","(","key",".","decode","(","'utf8'",")",")",".","split","(","'.'",")","[","0","]","for","key","in","ordered_req_dict",":","ordered_req_dict","[","key","]","[","'nick_name'","]","=","wxuin_nn_dict","[","key","]","ordered_req_dict","[","key","]","[","'wxuin'","]","=","key","ordered_req_dict","[","key","]","[","'nickname'","]","=","nickname","return","ordered_req_dict"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L38-L51"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.combine","parameters":"(req_dic)","argument_list":"","return_statement":"return tidy_req_dic","docstring":":param req_dic:\n :return: \u627e\u51fa\u4e00\u4e2a\u624b\u673a(\u8d26\u53f7)\u4ea7\u751f\u7684\u6700\u65b0\u8bf7\u6c42\u4fe1\u606f\n \uff5b\n 'wxuin1':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n 'wxuin2':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n }","docstring_summary":":param req_dic:\n :return: \u627e\u51fa\u4e00\u4e2a\u624b\u673a(\u8d26\u53f7)\u4ea7\u751f\u7684\u6700\u65b0\u8bf7\u6c42\u4fe1\u606f\n \uff5b\n 'wxuin1':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n 'wxuin2':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n }","docstring_tokens":[":","param","req_dic",":",":","return",":","\u627e\u51fa\u4e00\u4e2a\u624b\u673a","(","\u8d26\u53f7",")","\u4ea7\u751f\u7684\u6700\u65b0\u8bf7\u6c42\u4fe1\u606f","\uff5b","wxuin1",":","{","load_more",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","content",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","getappmsgext",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","appmsg_comment",":","{","update_time",":","1532859858625","req_data",":","{","...","}}}","wxuin2",":","{","load_more",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","content",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","getappmsgext",":","{","update_time",":","1532859858625","req_data",":","{","...","}}","appmsg_comment",":","{","update_time",":","1532859858625","req_data",":","{","...","}}}","}"],"function":"def combine(req_dic):\n \"\"\"\n :param req_dic:\n :return: \u627e\u51fa\u4e00\u4e2a\u624b\u673a(\u8d26\u53f7)\u4ea7\u751f\u7684\u6700\u65b0\u8bf7\u6c42\u4fe1\u606f\n \uff5b\n 'wxuin1':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n 'wxuin2':{\n 'load_more':{'update_time':'1532859858625','req_data':{...}},\n 'content':{'update_time':'1532859858625','req_data':{...}},\n 'getappmsgext':{'update_time':'1532859858625','req_data':{...}},\n 'appmsg_comment':{'update_time':'1532859858625','req_data':{...}}},\n }\n \"\"\"\n tidy_req_dic = {}\n # \u5efa\u7acb\u624b\u673a\u578b\u53f7\u7d22\u5f15\n for key in req_dic:\n wxuin = TidyReqData.get_wxuin(req_dic[key])\n if wxuin==\"NOT_WEIXIN\":\n continue\n tidy_req_dic[wxuin] = {}\n\n # \u4e3a\u6bcf\u4e2awxuin\u4e0b\u7684\u6570\u636e\u9884\u7559\u6570\u636e\u7c7b\u578b\n for wxuin in tidy_req_dic:\n tidy_req_dic[wxuin] = {}\n # \u7ec4\u7ec7all_req_data\u6570\u636e\n for key in req_dic:\n key_info = key.split('.')\n # \u83b7\u53d6\u4e00\u6b21\u8bf7\u6c42\u6570\u636e\u4e2d\u7684\u5143\u4fe1\u606f\n timestamp = int(key_info[0])\n _type = key_info[1]\n wxuin = TidyReqData.get_wxuin(req_dic[key])\n if wxuin==\"NOT_WEIXIN\":\n continue\n req_data = req_dic[key]\n\n # \u6784\u9020\u4e00\u90e8\u624b\u673a\u7684\u6a21\u62df\u8bf7\u6c42\u6570\u636e\u7ed3\u6784\n # \u91cd\u70b9\u5173\u6ce8\u7684\u662fall_req_data\u90e8\u5206\n all_req_data = tidy_req_dic[wxuin]\n # \u8be5\u79cd\u7c7b\u578b\u7684\u8bf7\u6c42\u6570\u636e\u5c1a\u672a\u51fa\u73b0\n if _type not in all_req_data:\n all_req_data[_type] = {}\n all_req_data[_type]['update_time'] = timestamp\n all_req_data[_type]['req_data'] = req_data\n # \u8be5\u79cd\u7c7b\u578b\u7684\u8bf7\u6c42\u6570\u636e\u5df2\u7ecf\u5b58\u5728\u6839\u636etimetamp\u548cupdate_time\u7684\u5bf9\u6bd4\u786e\u5b9a\u662f\u5426\u9700\u8981\u8986\u76d6\n else:\n if timestamp > all_req_data[_type]['update_time']:\n all_req_data[_type]['update_time'] = timestamp\n all_req_data[_type]['req_data'] = req_data\n return tidy_req_dic","function_tokens":["def","combine","(","req_dic",")",":","tidy_req_dic","=","{","}","# \u5efa\u7acb\u624b\u673a\u578b\u53f7\u7d22\u5f15","for","key","in","req_dic",":","wxuin","=","TidyReqData",".","get_wxuin","(","req_dic","[","key","]",")","if","wxuin","==","\"NOT_WEIXIN\"",":","continue","tidy_req_dic","[","wxuin","]","=","{","}","# \u4e3a\u6bcf\u4e2awxuin\u4e0b\u7684\u6570\u636e\u9884\u7559\u6570\u636e\u7c7b\u578b","for","wxuin","in","tidy_req_dic",":","tidy_req_dic","[","wxuin","]","=","{","}","# \u7ec4\u7ec7all_req_data\u6570\u636e","for","key","in","req_dic",":","key_info","=","key",".","split","(","'.'",")","# \u83b7\u53d6\u4e00\u6b21\u8bf7\u6c42\u6570\u636e\u4e2d\u7684\u5143\u4fe1\u606f","timestamp","=","int","(","key_info","[","0","]",")","_type","=","key_info","[","1","]","wxuin","=","TidyReqData",".","get_wxuin","(","req_dic","[","key","]",")","if","wxuin","==","\"NOT_WEIXIN\"",":","continue","req_data","=","req_dic","[","key","]","# \u6784\u9020\u4e00\u90e8\u624b\u673a\u7684\u6a21\u62df\u8bf7\u6c42\u6570\u636e\u7ed3\u6784","# \u91cd\u70b9\u5173\u6ce8\u7684\u662fall_req_data\u90e8\u5206","all_req_data","=","tidy_req_dic","[","wxuin","]","# \u8be5\u79cd\u7c7b\u578b\u7684\u8bf7\u6c42\u6570\u636e\u5c1a\u672a\u51fa\u73b0","if","_type","not","in","all_req_data",":","all_req_data","[","_type","]","=","{","}","all_req_data","[","_type","]","[","'update_time'","]","=","timestamp","all_req_data","[","_type","]","[","'req_data'","]","=","req_data","# \u8be5\u79cd\u7c7b\u578b\u7684\u8bf7\u6c42\u6570\u636e\u5df2\u7ecf\u5b58\u5728\u6839\u636etimetamp\u548cupdate_time\u7684\u5bf9\u6bd4\u786e\u5b9a\u662f\u5426\u9700\u8981\u8986\u76d6","else",":","if","timestamp",">","all_req_data","[","_type","]","[","'update_time'","]",":","all_req_data","[","_type","]","[","'update_time'","]","=","timestamp","all_req_data","[","_type","]","[","'req_data'","]","=","req_data","return","tidy_req_dic"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L58-L110"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.tidy","parameters":"()","argument_list":"","return_statement":"return tidy_req_data","docstring":"\u5bf9redis\u4e2d\u7684\u8bf7\u6c42\u6570\u636e\u6574\u7406\u5f52\u7eb3\uff0c\u627e\u51fa\u6bcf\u53f0\u624b\u673a\u6700\u65b0\u7684\u8bf7\u6c42\u6570\u636e\n :param redis:redis\u5b9e\u4f8b db\u5fc5\u987b\u548cproxy server\u5b58\u653e\u7684db\u76f8\u540c\n :return:\u6570\u636e\u683c\u5f0f\u89c1combine \u4e00\u65b9\u9762\u8fd4\u56de\u5b57\u5178\u53e6\u4e00\u65b9\u65b9\u9762\u5b58\u5165redis \u5e76\u4e14\u589e\u52a0\u5c5e\u6027 'update_time'","docstring_summary":"\u5bf9redis\u4e2d\u7684\u8bf7\u6c42\u6570\u636e\u6574\u7406\u5f52\u7eb3\uff0c\u627e\u51fa\u6bcf\u53f0\u624b\u673a\u6700\u65b0\u7684\u8bf7\u6c42\u6570\u636e\n :param redis:redis\u5b9e\u4f8b db\u5fc5\u987b\u548cproxy server\u5b58\u653e\u7684db\u76f8\u540c\n :return:\u6570\u636e\u683c\u5f0f\u89c1combine \u4e00\u65b9\u9762\u8fd4\u56de\u5b57\u5178\u53e6\u4e00\u65b9\u65b9\u9762\u5b58\u5165redis \u5e76\u4e14\u589e\u52a0\u5c5e\u6027 'update_time'","docstring_tokens":["\u5bf9redis\u4e2d\u7684\u8bf7\u6c42\u6570\u636e\u6574\u7406\u5f52\u7eb3\uff0c\u627e\u51fa\u6bcf\u53f0\u624b\u673a\u6700\u65b0\u7684\u8bf7\u6c42\u6570\u636e",":","param","redis",":","redis\u5b9e\u4f8b","db\u5fc5\u987b\u548cproxy","server\u5b58\u653e\u7684db\u76f8\u540c",":","return",":","\u6570\u636e\u683c\u5f0f\u89c1combine","\u4e00\u65b9\u9762\u8fd4\u56de\u5b57\u5178\u53e6\u4e00\u65b9\u65b9\u9762\u5b58\u5165redis","\u5e76\u4e14\u589e\u52a0\u5c5e\u6027","update_time"],"function":"def tidy():\n \"\"\"\n \u5bf9redis\u4e2d\u7684\u8bf7\u6c42\u6570\u636e\u6574\u7406\u5f52\u7eb3\uff0c\u627e\u51fa\u6bcf\u53f0\u624b\u673a\u6700\u65b0\u7684\u8bf7\u6c42\u6570\u636e\n :param redis:redis\u5b9e\u4f8b db\u5fc5\u987b\u548cproxy server\u5b58\u653e\u7684db\u76f8\u540c\n :return:\u6570\u636e\u683c\u5f0f\u89c1combine \u4e00\u65b9\u9762\u8fd4\u56de\u5b57\u5178\u53e6\u4e00\u65b9\u65b9\u9762\u5b58\u5165redis \u5e76\u4e14\u589e\u52a0\u5c5e\u6027 'update_time'\n \"\"\"\n tidy_req_data = TidyReqData.get_all_req_data()\n tidy_req_data = TidyReqData.combine(tidy_req_data)\n tidy_req_data = TidyReqData.add_nick_name(tidy_req_data)\n redis_instance.set('tidy_req_data',tidy_req_data)\n return tidy_req_data","function_tokens":["def","tidy","(",")",":","tidy_req_data","=","TidyReqData",".","get_all_req_data","(",")","tidy_req_data","=","TidyReqData",".","combine","(","tidy_req_data",")","tidy_req_data","=","TidyReqData",".","add_nick_name","(","tidy_req_data",")","redis_instance",".","set","(","'tidy_req_data'",",","tidy_req_data",")","return","tidy_req_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L113-L123"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.get_wxuin","parameters":"(req)","argument_list":"","return_statement":"return wxuin","docstring":":param req:\n :return:\u4eceredis\u4e2d\u4e00\u4e2a\u4e00\u6761req\u8bb0\u5f55\u4e2d\u63d0\u53d6wxuin \u7528\u4e8e\u8bc6\u522b\u4e0d\u540c\u7684\u5fae\u4fe1\u8d26\u53f7","docstring_summary":":param req:\n :return:\u4eceredis\u4e2d\u4e00\u4e2a\u4e00\u6761req\u8bb0\u5f55\u4e2d\u63d0\u53d6wxuin \u7528\u4e8e\u8bc6\u522b\u4e0d\u540c\u7684\u5fae\u4fe1\u8d26\u53f7","docstring_tokens":[":","param","req",":",":","return",":","\u4eceredis\u4e2d\u4e00\u4e2a\u4e00\u6761req\u8bb0\u5f55\u4e2d\u63d0\u53d6wxuin","\u7528\u4e8e\u8bc6\u522b\u4e0d\u540c\u7684\u5fae\u4fe1\u8d26\u53f7"],"function":"def get_wxuin(req):\n \"\"\"\n :param req:\n :return:\u4eceredis\u4e2d\u4e00\u4e2a\u4e00\u6761req\u8bb0\u5f55\u4e2d\u63d0\u53d6wxuin \u7528\u4e8e\u8bc6\u522b\u4e0d\u540c\u7684\u5fae\u4fe1\u8d26\u53f7\n \"\"\"\n try:\n cookie_string = req[\"requestOptions\"][\"headers\"][\"Cookie\"]\n except:\n return \"NOT_WEIXIN\"\n try:\n wxuin = re.findall(r'wxuin=\\S*?;', cookie_string)[0][6:-1]\n except:\n wxuin = cookie_string.split('wxuin=')[-1]\n return wxuin","function_tokens":["def","get_wxuin","(","req",")",":","try",":","cookie_string","=","req","[","\"requestOptions\"","]","[","\"headers\"","]","[","\"Cookie\"","]","except",":","return","\"NOT_WEIXIN\"","try",":","wxuin","=","re",".","findall","(","r'wxuin=\\S*?;'",",","cookie_string",")","[","0","]","[","6",":","-","1","]","except",":","wxuin","=","cookie_string",".","split","(","'wxuin='",")","[","-","1","]","return","wxuin"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L126-L139"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.flush_data","parameters":"(names=None)","argument_list":"","return_statement":"","docstring":":param names:\u53ef\u4f7f\u7528\u901a\u914d\u7b26\u683c\u5f0f\u7684key\u8868\u8fbe\u5f0f\u6bd4\u5982 *.req\n :return: \u5220\u9664redis\u4e2d\u7684\u70ed\u60c5\u6570\u636e","docstring_summary":":param names:\u53ef\u4f7f\u7528\u901a\u914d\u7b26\u683c\u5f0f\u7684key\u8868\u8fbe\u5f0f\u6bd4\u5982 *.req\n :return: \u5220\u9664redis\u4e2d\u7684\u70ed\u60c5\u6570\u636e","docstring_tokens":[":","param","names",":","\u53ef\u4f7f\u7528\u901a\u914d\u7b26\u683c\u5f0f\u7684key\u8868\u8fbe\u5f0f\u6bd4\u5982","*",".","req",":","return",":","\u5220\u9664redis\u4e2d\u7684\u70ed\u60c5\u6570\u636e"],"function":"def flush_data(names=None):\n \"\"\"\n :param names:\u53ef\u4f7f\u7528\u901a\u914d\u7b26\u683c\u5f0f\u7684key\u8868\u8fbe\u5f0f\u6bd4\u5982 *.req\n :return: \u5220\u9664redis\u4e2d\u7684\u70ed\u60c5\u6570\u636e\n \"\"\"\n if names==None:\n for key in redis_instance.keys():\n redis_instance.delete(key)\n for key in redis_instance.keys(names):\n redis_instance.delete(key)","function_tokens":["def","flush_data","(","names","=","None",")",":","if","names","==","None",":","for","key","in","redis_instance",".","keys","(",")",":","redis_instance",".","delete","(","key",")","for","key","in","redis_instance",".","keys","(","names",")",":","redis_instance",".","delete","(","key",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L142-L151"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.req_to_dict","parameters":"(raw_req_data)","argument_list":"","return_statement":"return req_data","docstring":":param raw_req_data:_type['req_data'] \u5b83\u53ea\u662f5\u79cd\u8bf7\u6c42\u6570\u636e\u7684\u4e00\u79cd\n :return:\u5c06anyproxy\u83b7\u53d6\u7684req\u6587\u4ef6\u5185\u5bb9\u89e3\u6790\u6210\u4e3arequest\u53c2\u6570\u6240\u9700\u8981\u7684\u5b57\u5178","docstring_summary":":param raw_req_data:_type['req_data'] \u5b83\u53ea\u662f5\u79cd\u8bf7\u6c42\u6570\u636e\u7684\u4e00\u79cd\n :return:\u5c06anyproxy\u83b7\u53d6\u7684req\u6587\u4ef6\u5185\u5bb9\u89e3\u6790\u6210\u4e3arequest\u53c2\u6570\u6240\u9700\u8981\u7684\u5b57\u5178","docstring_tokens":[":","param","raw_req_data",":","_type","[","req_data","]","\u5b83\u53ea\u662f5\u79cd\u8bf7\u6c42\u6570\u636e\u7684\u4e00\u79cd",":","return",":","\u5c06anyproxy\u83b7\u53d6\u7684req\u6587\u4ef6\u5185\u5bb9\u89e3\u6790\u6210\u4e3arequest\u53c2\u6570\u6240\u9700\u8981\u7684\u5b57\u5178"],"function":"def req_to_dict(raw_req_data):\n \"\"\"\n :param raw_req_data:_type['req_data'] \u5b83\u53ea\u662f5\u79cd\u8bf7\u6c42\u6570\u636e\u7684\u4e00\u79cd\n :return:\u5c06anyproxy\u83b7\u53d6\u7684req\u6587\u4ef6\u5185\u5bb9\u89e3\u6790\u6210\u4e3arequest\u53c2\u6570\u6240\u9700\u8981\u7684\u5b57\u5178\n \"\"\"\n req_data = {}\n url_lsit = raw_req_data['url'].split('?')\n url = url_lsit[0]+'?'\n req_data['url'] = url\n req_data['method'] = raw_req_data['requestOptions']['method']\n req_data['headers'] = raw_req_data['requestOptions']['headers']\n body_str = raw_req_data['requestData']\n body_dict = str_to_dict(body_str, \"&\", \"=\")\n url_param_str = url_lsit[1]\n url_param_dict = str_to_dict(url_param_str, \"&\", \"=\")\n req_data['body_dict'] = body_dict\n req_data['url_param_dict'] = url_param_dict\n # \u6dfb\u52a0\u4e00\u4e2a\u6d4b\u8bd5\u5b57\u6bb5\n req_data['url_param_str'] = url_param_str\n return req_data","function_tokens":["def","req_to_dict","(","raw_req_data",")",":","req_data","=","{","}","url_lsit","=","raw_req_data","[","'url'","]",".","split","(","'?'",")","url","=","url_lsit","[","0","]","+","'?'","req_data","[","'url'","]","=","url","req_data","[","'method'","]","=","raw_req_data","[","'requestOptions'","]","[","'method'","]","req_data","[","'headers'","]","=","raw_req_data","[","'requestOptions'","]","[","'headers'","]","body_str","=","raw_req_data","[","'requestData'","]","body_dict","=","str_to_dict","(","body_str",",","\"&\"",",","\"=\"",")","url_param_str","=","url_lsit","[","1","]","url_param_dict","=","str_to_dict","(","url_param_str",",","\"&\"",",","\"=\"",")","req_data","[","'body_dict'","]","=","body_dict","req_data","[","'url_param_dict'","]","=","url_param_dict","# \u6dfb\u52a0\u4e00\u4e2a\u6d4b\u8bd5\u5b57\u6bb5","req_data","[","'url_param_str'","]","=","url_param_str","return","req_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L154-L173"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/tidy_req_data.py","language":"python","identifier":"TidyReqData.get_gzh_req_data","parameters":"()","argument_list":"","return_statement":"return wx_num, req_data_dict, req_data_list","docstring":":return:\u8fd4\u56de\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u51c6\u5907\u7684\u6240\u6709\u8bf7\u6c42\u6570\u636e","docstring_summary":":return:\u8fd4\u56de\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u51c6\u5907\u7684\u6240\u6709\u8bf7\u6c42\u6570\u636e","docstring_tokens":[":","return",":","\u8fd4\u56de\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u51c6\u5907\u7684\u6240\u6709\u8bf7\u6c42\u6570\u636e"],"function":"def get_gzh_req_data():\n \"\"\"\n :return:\u8fd4\u56de\u4e3a\u4e00\u4e2a\u516c\u4f17\u53f7\u51c6\u5907\u7684\u6240\u6709\u8bf7\u6c42\u6570\u636e\n \"\"\"\n # \u6240\u6709\u8bf7\u6c42\u53c2\u6570\u5b57\u5178\u683c\u5f0f \u4f7f\u7528wxuin\u4f5c\u4e3akey\n req_data_dict = TidyReqData.tidy()\n # \u6240\u6709\u8bf7\u6c42\u53c2\u6570list\u683c\u5f0f \u65b9\u4fbf\u6309\u7167\u987a\u5e8f\u4f9d\u6b21\u4f7f\u7528\u5404\u4e2a\u5fae\u4fe1\u7684\u8bf7\u6c42\u53c2\u6570\n req_data_list = []\n for key in req_data_dict:\n req_data_list.append(req_data_dict[key])\n # \u53ef\u7528\u8bf7\u6c42\u53c2\u6570\u5fae\u4fe1\u6570\u91cf\n wx_num = len(req_data_list)\n return wx_num, req_data_dict, req_data_list","function_tokens":["def","get_gzh_req_data","(",")",":","# \u6240\u6709\u8bf7\u6c42\u53c2\u6570\u5b57\u5178\u683c\u5f0f \u4f7f\u7528wxuin\u4f5c\u4e3akey","req_data_dict","=","TidyReqData",".","tidy","(",")","# \u6240\u6709\u8bf7\u6c42\u53c2\u6570list\u683c\u5f0f \u65b9\u4fbf\u6309\u7167\u987a\u5e8f\u4f9d\u6b21\u4f7f\u7528\u5404\u4e2a\u5fae\u4fe1\u7684\u8bf7\u6c42\u53c2\u6570","req_data_list","=","[","]","for","key","in","req_data_dict",":","req_data_list",".","append","(","req_data_dict","[","key","]",")","# \u53ef\u7528\u8bf7\u6c42\u53c2\u6570\u5fae\u4fe1\u6570\u91cf","wx_num","=","len","(","req_data_list",")","return","wx_num",",","req_data_dict",",","req_data_list"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/tidy_req_data.py#L176-L188"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/decode_response.py","language":"python","identifier":"DecodeArticle.decode_content","parameters":"(r)","argument_list":"","return_statement":"return data","docstring":":param r:html\u5b57\u7b26\u4e32\n :return:\u89e3\u6790\u6587\u7ae0html\n \u6587\u7ae0html\u4e2d\u5305\u542b\u7684\u4fe1\u606f\u975e\u5e38\u4e30\u5bcc \u4e0d\u4ec5\u4ec5\u53ea\u6709\u6587\u7ae0\u6587\u672c\u7b49\u57fa\u672c\u6570\u636e\u8fd8\u6709comment_id\n video_num pic_num \u8fd8\u6709\u539f\u6587\u7684markdown\u4fe1\u606f","docstring_summary":":param r:html\u5b57\u7b26\u4e32\n :return:\u89e3\u6790\u6587\u7ae0html\n \u6587\u7ae0html\u4e2d\u5305\u542b\u7684\u4fe1\u606f\u975e\u5e38\u4e30\u5bcc \u4e0d\u4ec5\u4ec5\u53ea\u6709\u6587\u7ae0\u6587\u672c\u7b49\u57fa\u672c\u6570\u636e\u8fd8\u6709comment_id\n video_num pic_num \u8fd8\u6709\u539f\u6587\u7684markdown\u4fe1\u606f","docstring_tokens":[":","param","r",":","html\u5b57\u7b26\u4e32",":","return",":","\u89e3\u6790\u6587\u7ae0html","\u6587\u7ae0html\u4e2d\u5305\u542b\u7684\u4fe1\u606f\u975e\u5e38\u4e30\u5bcc","\u4e0d\u4ec5\u4ec5\u53ea\u6709\u6587\u7ae0\u6587\u672c\u7b49\u57fa\u672c\u6570\u636e\u8fd8\u6709comment_id","video_num","pic_num","\u8fd8\u6709\u539f\u6587\u7684markdown\u4fe1\u606f"],"function":"def decode_content(r):\n \"\"\"\n :param r:html\u5b57\u7b26\u4e32\n :return:\u89e3\u6790\u6587\u7ae0html\n \u6587\u7ae0html\u4e2d\u5305\u542b\u7684\u4fe1\u606f\u975e\u5e38\u4e30\u5bcc \u4e0d\u4ec5\u4ec5\u53ea\u6709\u6587\u7ae0\u6587\u672c\u7b49\u57fa\u672c\u6570\u636e\u8fd8\u6709comment_id\n video_num pic_num \u8fd8\u6709\u539f\u6587\u7684markdown\u4fe1\u606f\n \"\"\"\n data = {}\n r_data = r\n data['video_num'] = len(re.findall(REG_VIDEO_NUM, r_data))\n data['pic_num'] = len(re.findall(REG_PIC_NUM, r_data))\n data['comment_id'] = re.findall(REG_COMMENT_ID, r_data)\n if len(data['comment_id'])==1:data['comment_id']=data['comment_id'][0].split('\"')[1]\n else:data['comment_id'] = str(0)\n r_data = DecodeArticle.part_of_html(r_data)\n try:\n data['article'] = html_to_text.handle(r_data)\n except Exception as e:\n try:\n data['article'] = html_to_text.handle(r)\n except:\n data['article'] = \"\"\n return data","function_tokens":["def","decode_content","(","r",")",":","data","=","{","}","r_data","=","r","data","[","'video_num'","]","=","len","(","re",".","findall","(","REG_VIDEO_NUM",",","r_data",")",")","data","[","'pic_num'","]","=","len","(","re",".","findall","(","REG_PIC_NUM",",","r_data",")",")","data","[","'comment_id'","]","=","re",".","findall","(","REG_COMMENT_ID",",","r_data",")","if","len","(","data","[","'comment_id'","]",")","==","1",":","data","[","'comment_id'","]","=","data","[","'comment_id'","]","[","0","]",".","split","(","'\"'",")","[","1","]","else",":","data","[","'comment_id'","]","=","str","(","0",")","r_data","=","DecodeArticle",".","part_of_html","(","r_data",")","try",":","data","[","'article'","]","=","html_to_text",".","handle","(","r_data",")","except","Exception","as","e",":","try",":","data","[","'article'","]","=","html_to_text",".","handle","(","r",")","except",":","data","[","'article'","]","=","\"\"","return","data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/decode_response.py#L21-L43"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/decode_response.py","language":"python","identifier":"DecodeArticle.part_of_html","parameters":"(raw_html,x_path=r'\/\/div[@id=\"js_content\"]')","argument_list":"","return_statement":"","docstring":":param x_path:xpath\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u83b7\u53d6\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6b63\u6587xpath\n :param raw_html:r.text\n :return: \u622a\u53d6html\u7684\u4e00\u90e8\u5206","docstring_summary":":param x_path:xpath\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u83b7\u53d6\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6b63\u6587xpath\n :param raw_html:r.text\n :return: \u622a\u53d6html\u7684\u4e00\u90e8\u5206","docstring_tokens":[":","param","x_path",":","xpath\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u83b7\u53d6\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6b63\u6587xpath",":","param","raw_html",":","r",".","text",":","return",":","\u622a\u53d6html\u7684\u4e00\u90e8\u5206"],"function":"def part_of_html(raw_html,x_path=r'\/\/div[@id=\"js_content\"]'):\n \"\"\"\n :param x_path:xpath\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u83b7\u53d6\u5fae\u4fe1\u516c\u4f17\u53f7\u7684\u6b63\u6587xpath\n :param raw_html:r.text\n :return: \u622a\u53d6html\u7684\u4e00\u90e8\u5206\n \"\"\"\n from lxml import html\n tree = html.fromstring(raw_html)\n data = tree.xpath(x_path)\n if len(data) == 1:\n data = tostring(data[0], encoding='unicode')\n return data\n else:\n return raw_html","function_tokens":["def","part_of_html","(","raw_html",",","x_path","=","r'\/\/div[@id=\"js_content\"]'",")",":","from","lxml","import","html","tree","=","html",".","fromstring","(","raw_html",")","data","=","tree",".","xpath","(","x_path",")","if","len","(","data",")","==","1",":","data","=","tostring","(","data","[","0","]",",","encoding","=","'unicode'",")","return","data","else",":","return","raw_html"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/decode_response.py#L46-L59"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/decode_response.py","language":"python","identifier":"DecodeArticleList.decode_load_more","parameters":"(response)","argument_list":"","return_statement":"return use_data","docstring":":param response:\u8bf7\u6c42\u8fd4\u56de\u7684response\n :return:\u63d0\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u5e76\u4e14\u5206\u7c7b\u4e3b\u526f \u4e3b\u6587\u7ae0\u662f\u4e00\u6b21\u63a8\u9001\u7684\u5934\u6761\u6d88\u606f\u752810\u8868\u793a \u5176\u4f59\u6587\u7ae0\u4ece11\u5f00\u59cb\u8868\u793a\n r['r']['data']: title,digest,content_url,source_url,cover,author,mov,p_date,id\n r['r']['des']: can_msg_continue,next_offset","docstring_summary":":param response:\u8bf7\u6c42\u8fd4\u56de\u7684response\n :return:\u63d0\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u5e76\u4e14\u5206\u7c7b\u4e3b\u526f \u4e3b\u6587\u7ae0\u662f\u4e00\u6b21\u63a8\u9001\u7684\u5934\u6761\u6d88\u606f\u752810\u8868\u793a \u5176\u4f59\u6587\u7ae0\u4ece11\u5f00\u59cb\u8868\u793a\n r['r']['data']: title,digest,content_url,source_url,cover,author,mov,p_date,id\n r['r']['des']: can_msg_continue,next_offset","docstring_tokens":[":","param","response",":","\u8bf7\u6c42\u8fd4\u56de\u7684response",":","return",":","\u63d0\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u5e76\u4e14\u5206\u7c7b\u4e3b\u526f","\u4e3b\u6587\u7ae0\u662f\u4e00\u6b21\u63a8\u9001\u7684\u5934\u6761\u6d88\u606f\u752810\u8868\u793a","\u5176\u4f59\u6587\u7ae0\u4ece11\u5f00\u59cb\u8868\u793a","r","[","r","]","[","data","]",":","title","digest","content_url","source_url","cover","author","mov","p_date","id","r","[","r","]","[","des","]",":","can_msg_continue","next_offset"],"function":"def decode_load_more(response):\n \"\"\"\n :param response:\u8bf7\u6c42\u8fd4\u56de\u7684response\n :return:\u63d0\u53d6\u5386\u53f2\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u5e76\u4e14\u5206\u7c7b\u4e3b\u526f \u4e3b\u6587\u7ae0\u662f\u4e00\u6b21\u63a8\u9001\u7684\u5934\u6761\u6d88\u606f\u752810\u8868\u793a \u5176\u4f59\u6587\u7ae0\u4ece11\u5f00\u59cb\u8868\u793a\n r['r']['data']: title,digest,content_url,source_url,cover,author,mov,p_date,id\n r['r']['des']: can_msg_continue,next_offset\n \"\"\"\n use_data = dict()\n use_data['data'] = []\n use_data['des'] = {}\n use_data['id'] = 0\n\n data = json.loads(response.body_as_unicode())\n # \u6dfb\u52a0\u672c\u6b21\u83b7\u53d6\u5217\u8868\u4e4b\u540e\u662f\u5426\u53ef\u4ee5\u7ee7\u7eed\u4ee5\u53ca\u4e0b\u4e00\u4e2aoffset\n use_data['des']['can_msg_continue'] = data['can_msg_continue']\n use_data['des']['next_offset'] = data['next_offset']\n # \u904d\u5386\u6d88\u606f\u5217\u8868\n data = DecodeArticleList.general_msg_list_to_list(data.get('general_msg_list'))\n # \u89e3\u6790\u6d88\u606f\u5217\u8868\n for msg in data:\n p_date = msg.get(\"comm_msg_info\").get(\"datetime\")\n msg_info = msg.get(\"app_msg_ext_info\") # \u975e\u56fe\u6587\u6d88\u606f\u6ca1\u6709\u6b64\u5b57\u6bb5\n if msg_info:\n mov = 10\n msg_info['mov'] = str(mov)\n DecodeArticleList._insert(use_data, msg_info, p_date)\n multi_msg_info = msg_info.get(\"multi_app_msg_item_list\")\n for msg_item in multi_msg_info:\n mov += 1\n msg_item['mov'] = str(mov)\n DecodeArticleList._insert(use_data, msg_item, p_date)\n else:\n logger.warning(u\"\u6b64\u6d88\u606f\u4e0d\u662f\u56fe\u6587\u63a8\u9001\uff0cdata=%s\" % json.dumps(msg.get(\"comm_msg_info\")))\n use_data.pop('id')\n return use_data","function_tokens":["def","decode_load_more","(","response",")",":","use_data","=","dict","(",")","use_data","[","'data'","]","=","[","]","use_data","[","'des'","]","=","{","}","use_data","[","'id'","]","=","0","data","=","json",".","loads","(","response",".","body_as_unicode","(",")",")","# \u6dfb\u52a0\u672c\u6b21\u83b7\u53d6\u5217\u8868\u4e4b\u540e\u662f\u5426\u53ef\u4ee5\u7ee7\u7eed\u4ee5\u53ca\u4e0b\u4e00\u4e2aoffset","use_data","[","'des'","]","[","'can_msg_continue'","]","=","data","[","'can_msg_continue'","]","use_data","[","'des'","]","[","'next_offset'","]","=","data","[","'next_offset'","]","# \u904d\u5386\u6d88\u606f\u5217\u8868","data","=","DecodeArticleList",".","general_msg_list_to_list","(","data",".","get","(","'general_msg_list'",")",")","# \u89e3\u6790\u6d88\u606f\u5217\u8868","for","msg","in","data",":","p_date","=","msg",".","get","(","\"comm_msg_info\"",")",".","get","(","\"datetime\"",")","msg_info","=","msg",".","get","(","\"app_msg_ext_info\"",")","# \u975e\u56fe\u6587\u6d88\u606f\u6ca1\u6709\u6b64\u5b57\u6bb5","if","msg_info",":","mov","=","10","msg_info","[","'mov'","]","=","str","(","mov",")","DecodeArticleList",".","_insert","(","use_data",",","msg_info",",","p_date",")","multi_msg_info","=","msg_info",".","get","(","\"multi_app_msg_item_list\"",")","for","msg_item","in","multi_msg_info",":","mov","+=","1","msg_item","[","'mov'","]","=","str","(","mov",")","DecodeArticleList",".","_insert","(","use_data",",","msg_item",",","p_date",")","else",":","logger",".","warning","(","u\"\u6b64\u6d88\u606f\u4e0d\u662f\u56fe\u6587\u63a8\u9001\uff0cdata=%s\" % json.dumps(msg.ge","(","comm","_","msg_i","n","fo\"",")","))","","","","","","use_data",".","pop","(","'id'",")","return","use_data"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/decode_response.py#L66-L100"} {"nwo":"54xingzhe\/weixin_crawler","sha":"7e255e49717b7555424103398e16e2da40af4d38","path":"project\/crawler_assist\/decode_response.py","language":"python","identifier":"DecodeArticleList._insert","parameters":"(use_data, item, p_date)","argument_list":"","return_statement":"","docstring":"\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u63d2\u5165use_data","docstring_summary":"\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u63d2\u5165use_data","docstring_tokens":["\u6587\u7ae0\u5217\u8868\u4fe1\u606f\u63d2\u5165use_data"],"function":"def _insert(use_data, item, p_date):\n '''\n \u6587\u7ae0\u5217\u8868\u4fe1\u606f\u63d2\u5165use_data\n '''\n use_data['id'] += 1\n keys = ('title', 'author', 'content_url', 'digest', 'cover', 'source_url','mov')\n sub_data = DecodeArticleList.sub_dict(item, keys)\n p_date = datetime.fromtimestamp(p_date)\n sub_data[\"p_date\"] = p_date\n use_data['data'].append(sub_data)\n logger.info('%d %s %s'%(use_data[\"id\"],sub_data[\"mov\"], sub_data[\"title\"]))","function_tokens":["def","_insert","(","use_data",",","item",",","p_date",")",":","use_data","[","'id'","]","+=","1","keys","=","(","'title'",",","'author'",",","'content_url'",",","'digest'",",","'cover'",",","'source_url'",",","'mov'",")","sub_data","=","DecodeArticleList",".","sub_dict","(","item",",","keys",")","p_date","=","datetime",".","fromtimestamp","(","p_date",")","sub_data","[","\"p_date\"","]","=","p_date","use_data","[","'data'","]",".","append","(","sub_data",")","logger",".","info","(","'%d %s %s'","%","(","use_data","[","\"id\"","]",",","sub_data","[","\"mov\"","]",",","sub_data","[","\"title\"","]",")",")"],"url":"https:\/\/github.com\/54xingzhe\/weixin_crawler\/blob\/7e255e49717b7555424103398e16e2da40af4d38\/project\/crawler_assist\/decode_response.py#L109-L119"}