Click on " Python Crawler and Data Mining " above to pay attention
Reply to " Books " to get a total of 10 e-books on Python from entry to advanced
now
Day
chicken
Soup
The big strings are noisy like torrential rain, and the small strings are like whispers.
Hello everyone, I am Pippi.
I. Introduction
A few days ago in the Python strongest king group [鶏 ah 鶏. ] I asked a Python
question about a web crawler, and I will share it with you here.
The last two articles have given two solutions. The first method is to directly request the url of the picture, and then identify it, which is also very efficient; the second method is to directly locate the picture, and then complete the screenshot, and then to identify. In this article, let's take a look at the third solution.
2. Implementation process
This method is provided by [Wei Ge], which uses a third-party code platform called [Super Eagle]. I believe many friends have heard of it, so I will share it with you here.
The idea is actually similar to the second method, which is to locate the verification code picture first, then use the coding platform to identify it, then return the verification code, and then enter the account number and password to complete the login operation. The code is as follows:
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from PIL import Image
import ddddocr
from chaojiying import Chaojiying_Client
ocr = ddddocr.DdddOcr()
options = webdriver.ChromeOptions()
options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36')
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(options=options)
# 打开目标网页
driver.get('https://sol.sinosure.com.cn')
time.sleep(3)
# 处理验证码
img = driver.find_element(By.XPATH, '//*[@id="codeimage"]').screenshot_as_png
chaojiying = Chaojiying_Client('666', '666', '923043')
print(chaojiying.PostPic(img, 1902)) # 得到的是一个字典的返回结果
dic = chaojiying.PostPic(img, 1902)
verify_code = dic["pic_str"]
print(verify_code)
After the code is run, the verification code can also be obtained smoothly. For the verification code problem, three methods have been given so far. If you have other solutions, welcome to share!
3. Summary
Hello everyone, I am Pippi. This article mainly takes stock of Python
the problem of a web crawler passing verification codes. Aiming at this problem, the article gives specific analysis and code implementation to help fans solve the problem smoothly.
Finally, I would like to thank fans [鶏啊鶏] for asking questions, thank [Classmate Ning], [Brother Wei], [Teacher Yuliang], [Zheng Yuzhe Xiaopang], [Brother Dong] for their ideas and code analysis, and thanks to [Ineverleft], etc. People participate in learning exchanges.
[Supplementary questions] Warm reminder, when you ask questions in the group. You can pay attention to the following points: if it involves large file data, you can desensitize the data, send some demo data (meaning small files), and then paste some code (the kind that can be copied), and remember to send the screenshot of the error report (complete cut ). If there are not many codes, just send the code text directly. If the code exceeds 50 lines, just send a .py file.
If you have any problems during the learning process, please feel free to contact me to solve them (my WeChat: pdcfighting1). At the request of fans, I have created some high-quality Python paid learning exchange groups and paid order receiving groups. Welcome everyone to join me Python learning exchange group and order receiving group!
Friends, hurry up and practice it! If you encounter any problems during the learning process, please add me as a friend, and I will pull you into the Python learning exchange group to discuss learning together.
------------------- End -------------------
Recommendations for past wonderful articles:
Welcome everyone to like, leave a message, forward, repost, thank you for your company and support
If you want to join the Python learning group, please reply in the background [ join the group ]
Thousands of rivers and thousands of mountains are always in love, can you click [ Looking ]
/Today's Message Topic/
Just say a few words~~