學習英文與了解天下事,為什麼要讀時代雜誌呢?

閱讀世界新鮮事的人所擁有的國際觀是非常驚人的

當你開始閱讀time時代雜誌增加英文閱讀能力,同時也可以提昇世界觀

因此無論出社會還是在學時,推薦學英文的其中一種方法就是大量閱讀time時代雜誌

藉此提高外文的閱讀理解能力,提高英文文章與新聞的理解力,time時代雜誌是一個非常好的讀物!

因為這本雜誌所囊括世界各地最新的奇人異事,可以讓眼界變得更寬廣

而且許多最新片語詞彙,不見得你在字典可以找到,很多都是新創名詞

讓你的頭腦可以跟著世界的巨輪一起前進

只要閱讀1-2個月,你會發現你看原文的速度至少快上2-3倍。

除了TIME雜誌外,經濟學人,科學人,國家地理中文都很推薦

下面的介紹,可以讓你快速了解雜誌的特色

↓↓↓TIME雜誌限量特惠的優惠按鈕↓↓↓

PTT鄉民限量,團購,限時,週年慶,Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別禮物,優惠,特價,開箱,比價Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別,活動,好評,推薦

Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別01網友哪裡便宜,採購,優缺點,試用,Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別好用,Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別CP值,經驗,好康,集購,下殺,免比價,去哪買?,

名人推薦介紹,Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別部落客,排行,體驗,精選,限定,折扣,Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別折價卷,ptt,蝦皮拍賣,Dcard推薦評比開箱

選購指南!Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別這新知
如何選購Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別這新知
新手選購有技巧!部落客大推Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別這新知
Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別好用
這個這新知Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別你不能錯過
熱門的Python+scrapy爬蟲識別驗證碼(四)手繪驗證碼識別好用?如何選購

↓↓↓下方有其他推薦產品與服務讓你選喔↓↓↓

熱點新知搶先報

 

一、介紹 今天主要介紹的是微博客戶端在登錄時出現的四宮格手繪驗證碼,不多說直接看看驗證碼長成什麼樣。 ............ 二、思路 1、由於微博上的手繪驗證碼只有四個宮格,且每個宮格之間都有有向線段連接,所以我們可以判斷四個宮格不同方向的驗證碼一共有24種, 我們將四個宮格進行標號,得到的結果如下: ... 則我們可以排列出24種不同的手繪方向的驗證碼,分別為一下24種 ... 2、我們通過獲取到微博客戶端的24種手繪驗證碼後需要進行模板匹配,這樣通過全圖匹配的方式進行滑動。 三、代碼實現 1、首先是要通過微博移動端(https://passport.weibo.cn/signin/login)批量獲取手繪驗證碼,但是這個驗證碼不一定出現, 只有在帳號存在風險或者頻繁登錄的時候才會出現。獲取手繪驗證碼的代碼如下: 注意:需要將模擬瀏覽器所以元素(用戶名框,密碼框)加載完了才能發送用戶名和密碼,否則報錯 # -*- coding:utf-8 -*- import time from io import BytesIO from PIL import Image from selenium import webdriver from selenium.webdriver.common.by import By from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class CrackWeiboSlide(): def __init__(self): self.url = "https://passport.weibo.cn/signin/login?entry=mweibo&r=https://m.weibo.cn/" self.browser = webdriver.Chrome(r"D:chromedriver.exe") self.browser.maximize_window() self.wait = WebDriverWait(self.browser,5) def __del__(self): self.browser.close() def open(self): # 打開模擬瀏覽器 self.browser.get(self.url) # 獲取用戶名元素 username = self.wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="loginName"]'))) # 獲取密碼框元素 password = self.wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="loginPassword"]'))) # 獲取登錄按鈕元素 submit = self.wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="loginAction"]'))) # 提交數據並登錄 username.send_keys("15612345678") password.send_keys("xxxxxxxxxxxx") submit.click() def get_image(self,name = "captcha.png"): try: # 獲取驗證碼圖片元素 img = self.wait.until(EC.presence_of_element_located((By.CLASS_NAME,"patt-shadow"))) time.sleep(1) # 獲取驗證碼圖片所在的位置 location = img.location # 獲取驗證碼圖片的大小 size = img.size top = location["y"] # 上 bottom = location["y"] + size["height"] # 下 left = location["x"] # 左 right = location["x"] + size["width"] # 右 print("驗證碼的位置:", left, top, right, bottom) # 將當前窗口進行截屏 screenshot = self.browser.get_screenshot_as_png() # 讀取截圖 screenshot = Image.open(BytesIO(screenshot)) # 剪切九宮格圖片驗證碼 captcha = screenshot.crop((left, top, right, bottom)) # 將剪切的九宮格驗證碼保存到指定位置 captcha.save(name) print("微博登錄驗證碼保存完成!!!") return captcha except TimeoutException: print("沒有出現驗證碼!!") # 回調打開模擬瀏覽器函數 self.open() def main(self): count = 1 while True: # 調用打開模擬瀏覽器函數 self.open() # 調用獲取驗證碼圖片函數 self.get_image(str(count) + ".png") count += 1 if __name__ == '__main__': crack = CrackWeiboSlide() crack.main() 得到的24種手繪驗證碼,同時需要對這些手繪驗證碼根據上邊的編號進行命名 ...... 上圖就是我們需要的模板,接下來我們進行遍歷模板匹配即可 2、模板匹配 通過遍歷手繪驗證碼模板進行匹配 import os import time from io import BytesIO from PIL import Image from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class CrackWeiboSlide(): def __init__(self): self.url = "https://passport.weibo.cn/signin/login?entry=mweibo&r=https://m.weibo.cn/" self.browser = webdriver.Chrome(r"D:chromedriver.exe") self.browser.maximize_window() self.wait = WebDriverWait(self.browser,5) def __del__(self): self.browser.close() def open(self): # 打開模擬瀏覽器 self.browser.get(self.url) # 獲取用戶名元素 username = self.wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="loginName"]'))) # 獲取密碼框元素 password = self.wait.until(EC.presence_of_element_located((By.XPATH,'//*[@id="loginPassword"]'))) # 獲取登錄按鈕元素 submit = self.wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="loginAction"]'))) # 提交數據並登錄 username.send_keys("15612345678") password.send_keys("xxxxxxxxxxxx") submit.click() def get_image(self,name = "captcha.png"): try: # 獲取驗證碼圖片元素 img = self.wait.until(EC.presence_of_element_located((By.CLASS_NAME,"patt-shadow"))) time.sleep(1) # 獲取驗證碼圖片所在的位置 location = img.location # 獲取驗證碼圖片的大小 size = img.size top = location["y"] # 上 bottom = location["y"] + size["height"] # 下 left = location["x"] # 左 right = location["x"] + size["width"] # 右 print("驗證碼的位置:", left, top, right, bottom) # 將當前窗口進行截屏 screenshot = self.browser.get_screenshot_as_png() # 讀取截圖 screenshot = Image.open(BytesIO(screenshot)) # 剪切九宮格圖片驗證碼 captcha = screenshot.crop((left, top, right, bottom)) # 將剪切的九宮格驗證碼保存到指定位置 captcha.save(name) print("微博登錄驗證碼保存完成!!!") # 返回微博移動端的驗證碼圖片 return captcha except TimeoutException: print("沒有出現驗證碼!!") # 回調打開模擬瀏覽器函數 self.open() def is_pixel_equal(self,image,template,i,j): # 取出兩張圖片的像素點 pixel1 = image.load()[i,j] # 移動客戶端獲取的驗證碼 pixel2 = template.load()[i,j] # 模板文件里的驗證碼 threshold = 20 # 閾值 pix_r = abs(pixel1[0] - pixel2[0]) # R pix_g = abs(pixel1[1] - pixel2[1]) # G pix_b = abs(pixel1[2] - pixel2[2]) # B if (pix_r< threshold) and (pix_g< threshold ) and (pix_b< threshold) : return True else: return False def same_image(self,image,template): """ :param image: 微博移動端獲取的驗證碼圖片 :param template: 通過模板文件獲取的驗證碼圖片 """ threshold = 0.99 # 相似度閾值 count = 0 # 遍歷微博移動端獲取的驗證碼圖片的寬度和高度 for i in range(image.width): for j in range(image.height): # 判斷兩張圖片的像素是否相等 if self.is_pixel_equal(image,template,i,j): count += 1 result = float(count)/(image.width*image.height) if result >threshold: print("匹配成功!!!") return True else: return False def detect_image(self,image): # 遍歷手繪驗證碼模板文件內的所有驗證碼圖片 for template_name in os.listdir(r"D:photo emplates"): print("正在匹配",template_name) # 打開驗證碼圖片 template = Image.open(r"D:photo emplates{}".format(template_name)) if self.same_image(image,template): # 返回這張圖片的順序,如4—>3—>1—>2 numbers = [int(number) for number in list(template_name.split(".")[0])] print("按照順序進行拖動",numbers) return numbers def move(self,numbers): # 獲得四個按點 circles = self.browser.find_element_by_css_selector('.patt-wrap .patt-circ') dx = dy = 0 # 由於是四個宮格,所以需要循環四次 for index in range(4): circle = circles[numbers[index] - 1] # 如果是第一次循環 if index == 0: # 點擊第一個點 action = ActionChains(self.browser).move_to_element_with_offset(circle,circle.size["width"]/2,circle.size['height']/2) action.click_and_hold().perform() else: # 小幅度移動次數 times = 30 # 拖動 for i in range(times): ActionChains(self.browser).move_by_offset(dx/times,dy/times).perform() time.sleep(1/times) # 如果是最後一次循環 if index == 3: # 鬆開滑鼠 ActionChains(self.browser).release().perform() else: # 計算下一次偏移 dx = circles[numbers[index + 1] - 1].location['x'] - circle.location['x'] dy = circles[numbers[index + 1] - 1].location['y'] - circle.location['y'] def main(self): # 調用打開模擬瀏覽器函數 self.open() image = self.get_image("captcha.png") # 微博移動端的驗證碼圖片 numbers = self.detect_image(image) self.move(numbers) time.sleep(10) print('識別結束') if __name__ == '__main__': crack = CrackWeiboSlide() crack.main() 四、識別結果 通過循環四次後繪出四條方向,最終得到效果圖 ...

 

D15RF15FVFR5RR151EFE

 

 

文章來源取自於:

 

 

每日頭條 https://kknews.cc/tech/9vbkmob.html

如有侵權,請來信告知,我們會立刻下架。

DMCA:dmca(at)kubonews.com

聯絡我們:contact(at)kubonews.com


家庭育兒雜誌桃園哪裡訂國際書展科普雜誌苗栗哪裡訂家庭育兒雜誌台南哪裡訂美國商業週刊南投哪裡訂
國際書展National Geographic優惠訂閱價格 美國大學轉學,你必須知道的那些事兒2020年科學人台中哪裡訂 中式教育有多強?北京大學培養一個非洲學生,回國順利當上總統(1)2020年商業周刊高雄哪裡訂 熱度最高的防曬測評,看看有你的同款嗎?國際書展經濟學人哪裡訂便宜 宋慧喬最新夏日畫報,穿上連衣裙又變少女了,依舊很耐看

arrow
arrow
    全站熱搜

    pglg6ubyoj 發表在 痞客邦 留言(0) 人氣()