In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge about "Python crawler encounters Captcha how to solve it." In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
I. Preface
The registration page of China Zhiwang uses this Captcha. The page is as follows:
II. Preparatory work
1 goal
Taking the Captcha of Zhiwang as an example, OCR (Optical Character Recognition) technology is used to identify the graphic Captcha.
2 Installing tesseract
2.2 Download tesseract-ocr-setup-3.05.01.exe
2.3 installation considerations
Check the Additional language data (download) option to recognize multiple languages.
3 Install tesserocr
pip install tesserocr pillow
After Tesseract-OCR is installed, copy the tesseract-OCR folder from D:\Program Files (x86)\Tesseract-OCR to the following directory
E:\WebSpider\venv\Scripts
4Get Captcha
Save the Captcha graphic locally and name it code.jpg
Three battles.
1 actual combat
1.1 code
import tesserocrfrom PIL import Image image = Image.open('code.jpg')result = tesserocr.image_to_text(image)print(result) image = Image.open('code1.jpg')result = tesserocr.image_to_text(image)print(result) image = Image.open('code2.jpg')result = tesserocr.image_to_text(image)print(result)
1.2 effect
E:\WebSpider\venv\Scripts\python.exe E:/WebSpider/8_1.pyDTKDJR42PFRT
1.3 description
code.jpg is DTKT
code1.jpg is JR42
code2.jpg is PFRT
Comparing the results with actual pictures, the accuracy rate is still relatively high.
2 Combat 2
2.1 code
import tesserocr print(tesserocr.file_to_text('code.jpg'))print(tesserocr.file_to_text('code1.jpg'))print(tesserocr.file_to_text('code2.jpg'))
2.2 effect
E:\WebSpider\venv\Scripts\python.exe E:/WebSpider/8_1.pyDTKD.ll? 42FFKT
2.3 description
code.jpg is DTKT
code1.jpg is JR42
code2.jpg is PFRT
Comparing the results with actual pictures, the accuracy rate is not very high.
3 Combat 3
3.1 code
import tesserocrfrom PIL import Image image = Image.open('code2.jpg') image = image.convert('L')threshold = 127table = []for i in range(256): if i < threshold: table.append(0) else: table.append(1) image = image.point(table, '1')image.show() result = tesserocr.image_to_text(image)print(result)
3.2 effect
E:\WebSpider\venv\Scripts\python.exe E:/WebSpider/8_1.pyPFRT"Python crawler encountered Captcha how to solve" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.