for it in result1: urls = it.group('urls') # print(urls) result2 = regObj2.finditer(urls) for itt in result2: src = itt.group("srcs") # print(src) img_resp = requests.get(src) img_name = src.split("/")[-1] withopen("./Pics/"+img_name,mode="wb") as f: f.write(img_resp.content) print("over!",img_name)
print("All over!!")
执行后会在当前目录下创建Pics文件夹
OCR批量识别代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import pytesseract from PIL import Image
if __name__ == '__main__': for i inrange(1,137): filename = "./Pics/"+str(i)+".png" text = pytesseract.image_to_string(Image.open(filename), lang="chi_sim") # 如果你想试试Tesseract识别中文,只需要将代码中的eng改为chi_sim即可 # print(text) withopen('./readme.txt', 'a') as f: f.write(text) f.write("\n") print(str(i)+".png success!")