通过结合使用scrapy在python中从图像中获取文本的基本网址? [英] by combining base url getting text out of image in python using scrapy?
本文介绍了通过结合使用scrapy在python中从图像中获取文本的基本网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试过这个代码:
src1 = "https://hms.harvard.edu/"<br/>
src = response.css('div.person-line > div >
img::attr("src")').extract_first()<br/>
src = sites/default/files/hms-faculty-emails/BX0UVXkP.jpg <br/>
import urlparse <br/>
urlparse.urljoin(src1, src)<br/>
https://hms.harvard.edu/sites/default/files/hms-faculty-emails/BX0UVXkP.jpg<br/>
src2 = urlparse.urljoin(src1,src)<br/>
email = pytesseract.image_to_string(Image.open(src2))<br/>
我收到此错误
ioerror errno 22 invalid mode ('rb') or filename
如何从文本图像中获取电子邮件文本..有人可以帮忙吗?
how to get email text out of text image..can any one help please?
推荐答案
你应该使用 io.BufferIO
缓冲区,因为你用 http<调用函数
image_to_string
/代码> 路径.你需要写这样的代码:
You should use io.BufferIO
buffer, because you call function image_to_string
with http
path. You need write code like this:
def get_text(src):
response = urlopen(src)
buffer = io.BytesIO(response.read())
return pytesseract.image_to_string(Image.open(buffer))
这篇关于通过结合使用scrapy在python中从图像中获取文本的基本网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文