最近学习python,磕磕碰碰写了一个根据关键字使用多线程爬取百度图片的程序。代码如下:
import os
import urllib.request
import threading
import re
#获取本地的要搜索关键字的名单
def getNameList(filename):
#没加encoding='utf-8'导致UnicodeDecodeError: 'gbk' codec can't decode byte 0x8f in position 14: illegal multibyte sequence
file = open(filename,encoding='utf-8')
keywordlist = file.readlines()
for i in range(len(keywordlist)):
keywordlist[i] = keywordlist[i].replace(