MCPcopy Index your code
hub / github.com/Jack-Cherish/python-spider / Crack

Class Crack

geetest.py:76–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 return full_bg_path
75
76class Crack():
77 def __init__(self,keyword):
78 self.url = '*'
79 self.browser = webdriver.Chrome('D:\\chromedriver.exe')
80 self.wait = WebDriverWait(self.browser, 100)
81 self.keyword = keyword
82 self.BORDER = 6
83
84 def open(self):
85 """
86 打开浏览器,并输入查询内容
87 """
88 self.browser.get(self.url)
89 keyword = self.wait.until(EC.presence_of_element_located((By.ID, 'keyword_qycx')))
90 bowton = self.wait.until(EC.presence_of_element_located((By.CLASS_NAME, 'btn')))
91 keyword.send_keys(self.keyword)
92 bowton.click()
93
94 def get_images(self, bg_filename = 'bg.jpg', fullbg_filename = 'fullbg.jpg'):
95 """
96 获取验证码图片
97 :return: 图片的location信息
98 """
99 bg = []
100 fullgb = []
101 while bg == [] and fullgb == []:
102 bf = BeautifulSoup(self.browser.page_source, 'lxml')
103 bg = bf.find_all('div', class_ = 'gt_cut_bg_slice')
104 fullgb = bf.find_all('div', class_ = 'gt_cut_fullbg_slice')
105 bg_url = re.findall('url\(\"(.*)\"\);', bg[0].get('style'))[0].replace('webp', 'jpg')
106 fullgb_url = re.findall('url\(\"(.*)\"\);', fullgb[0].get('style'))[0].replace('webp', 'jpg')
107 bg_location_list = []
108 fullbg_location_list = []
109 for each_bg in bg:
110 location = {}
111 location['x'] = int(re.findall('background-position: (.*)px (.*)px;',each_bg.get('style'))[0][0])
112 location['y'] = int(re.findall('background-position: (.*)px (.*)px;',each_bg.get('style'))[0][1])
113 bg_location_list.append(location)
114 for each_fullgb in fullgb:
115 location = {}
116 location['x'] = int(re.findall('background-position: (.*)px (.*)px;',each_fullgb.get('style'))[0][0])
117 location['y'] = int(re.findall('background-position: (.*)px (.*)px;',each_fullgb.get('style'))[0][1])
118 fullbg_location_list.append(location)
119
120 urlretrieve(url = bg_url, filename = bg_filename)
121 print('缺口图片下载完成')
122 urlretrieve(url = fullgb_url, filename = fullbg_filename)
123 print('背景图片下载完成')
124 return bg_location_list, fullbg_location_list
125
126 def get_merge_image(self, filename, location_list):
127 """
128 根据位置对图片进行合并还原
129 :filename:图片
130 :location_list:图片位置
131 """
132 im = image.open(filename)
133 new_im = image.new('RGB', (260,116))

Callers 1

geetest.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected