驗(yàn)證碼識別
安裝:參考https://blog.csdn.net/weixin_43849588/article/details/89922327
遇到的問題:環(huán)境變量配置好了后奢讨,輸入tesseract沒反應(yīng)酒请。乘客。态兴。這時(shí)重啟一下powershell就好了粥庄。
可以直接識別英文份乒,中文要指定
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = r"D:/Tesseract-OCR/tesseract.exe"
image = Image.open('04.jpg')
text = pytesseract.image_to_string(image,lang='chi_sim')
print(text)
pip install scrapy和pip install pypiwin32
pip install pypiwin32報(bào)錯(cuò):
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes.
因?yàn)榫W(wǎng)速太慢了腿堤,再試幾次
pip install scrapy報(bào)錯(cuò):
install for Twisted ... error
ERROR: Command "'c:\users\asus\appdata\local\programs\python\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\ASUS\\AppData\\Local\\Temp\\pip-install-eo8g5wdm\\twisted\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ASUS\AppData\Local\Temp\pip-record-s4l52cbr\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ASUS\AppData\Local\Temp\pip-install-eo8g5wdm\twisted\
因?yàn)闆]有裝twisted,要找對應(yīng)python版本的twist下載波势,放到python安裝目錄的Scripts 目錄下
網(wǎng)址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
但是這個(gè)很慢翎朱。橄维。
我傳到了網(wǎng)盤:Twisted-19.2.1-cp36、37闭翩、38—64位的
鏈接:https://pan.baidu.com/s/1kn59Wsrv3OHllgSEYu2svg
提取碼:j7dg
復(fù)制這段內(nèi)容后打開百度網(wǎng)盤手機(jī)App挣郭,操作更方便哦
然后再pip install 這個(gè)whl(要么到這個(gè)路徑下,要么寫上絕對路徑\文件名)安裝這個(gè)
之后再pip install scrapy就能成功了
爬取糗事百科
優(yōu)化:
轉(zhuǎn)化成字典
另一種:數(shù)據(jù)量多的時(shí)候