识别图像数字
import io
import requests
from urllib.parse import urljoin
from lxml import etree
from parsel import Selector
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
url = 'http://www.porters.vip/confusion/recruit.html'
resp = requests.get(url)
html=etree.HTML(resp.text)
tu=html.xpath('normalize-space(//tr[1]/td[2]/img/@src)')
print(tu)
image_url='http://www.porters.vip/confusion/{}'.format(tu)
image_body = requests.get(image_url).content # 使用Image.open打开图片字节流,得到图片对象
image_stream = Image.open(io.BytesIO(image_body)) # 使用光学字符识别从图片对象中读取文字并打印输出结果
print(pytesseract.image_to_string(image_stream)) #这段代码运行后的输出结果为
灰度
import requests
from faker import Faker
from lxml import etree
import muggle_ocr
from PIL import Image
import io
import redis
import json
import time
后期补…