摘要: 一、滑动验证码:(以企查查为例) from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver import ActionChain 阅读全文
posted @ 2020-11-24 11:25 Eliphaz 阅读(657) 评论(0) 推荐(0) 编辑
摘要: 一、什么是Celery 1.1、celery是什么 Celery的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成 消息中间件 Celery本身不提供消息服务,但是可以方便的和第三方提供的消息中间件 阅读全文
posted @ 2020-11-13 20:01 Eliphaz 阅读(273) 评论(6) 推荐(0) 编辑
摘要: 一、线程与进程的关系 默认一个进程至少一个线程 (1)区别:进程只是占内存,线程才消耗CPU; 线程在进程下行进 同一进程下不同线程间数据很易共享 二、全局解释器锁(GIL) GIL是解释器用于同步线程的一种机制,只允许同一时间执行一个线程 常见的GIL解释器有:Cpython与Ruby MRI 三 阅读全文
posted @ 2020-11-10 13:49 Eliphaz 阅读(126) 评论(0) 推荐(0) 编辑
摘要: text = response.text.encode() #获取页面编码 code = chardet.detect(text) #code 的输出是这样的的一个字典{'confidence': 0.99, 'encoding': 'utf-8'} response.encoding = code 阅读全文
posted @ 2020-10-23 20:44 Eliphaz 阅读(92) 评论(0) 推荐(0) 编辑
摘要: import time # 输入毫秒级的时间,转出正常格式的时间 # def timeStamp(timeNum): timeStamp = float(1603346322020/1000) timeArray = time.localtime(timeStamp) otherStyleTime 阅读全文
posted @ 2020-10-21 15:45 Eliphaz 阅读(8384) 评论(0) 推荐(0) 编辑
摘要: 通过 Google 的Chrome Devtools-Protocol(Chrome 开发工具协议)简称CDP,给定一段 JavaScript 代码,让 Chrome 刚刚打开页面,还没有运行网站自带的 JavaScript代码时,执行给定的代码。 使用driver.execute_cdp_cmd: 阅读全文
posted @ 2020-10-10 14:51 Eliphaz 阅读(1099) 评论(0) 推荐(0) 编辑
摘要: import langid from translate import Translator #语言处理 想要翻译更多种语言用langid去得到语言的代号进行判断 def tranlation(text): ''' :param text: input need translate language 阅读全文
posted @ 2020-09-30 16:36 Eliphaz 阅读(694) 评论(0) 推荐(0) 编辑
摘要: 最近项目中需要去判断进程爬虫是否正在运行,本来使用win32com,但是发现在被django view.py中调用的时候居然总是提示‘Invalid syntax’,后来换用psutil就能正常运行。并且psutil是跨平台的。 一、使用win32com来判断进程是否存在 import os imp 阅读全文
posted @ 2020-09-18 16:36 Eliphaz 阅读(467) 评论(0) 推荐(0) 编辑
摘要: import time import unittest from selenium import webdriver #iwebshop_login_testcase.py class IwebshopLoginTest(unittest.TestSuite): def setUp(self): s 阅读全文
posted @ 2020-09-16 20:25 Eliphaz 阅读(133) 评论(0) 推荐(0) 编辑
摘要: (1)基本布尔型断言 (2)比较断言 例子: import unittest def add(a,b): return a+b #继承unittest.TestCase类 class TestCase01(unittest.TestCase): #方法名必须以test开头 def testcase_ 阅读全文
posted @ 2020-09-16 15:42 Eliphaz 阅读(177) 评论(0) 推荐(0) 编辑