背景:在写一个自动去射手网爬字幕的字幕搜索脚本代码如下importsysimporturllib2importrequestsimportrereload(sys)sys.setdefaultencoding("utf-8")defdownload(searchname):header={'Host':'sub.makedie.me','Pragma':'no-cache','Referer':'http://sub.makedie.me/','Upgrade-Insecure-Requests':'1','User-Agent':'Mozilla/5.0(X11;Linuxx86_64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/46.0.2490.71Safari/537.36'}payload={'searchword':searchname}url='http://sub.makedie.me/sub/'s=requests.Session()response=s.get(url,params=payload,headers=header)ifresponse.status_code==requests.codes.ok:file=response.textreturnfilefile_temp=open('filetemp.txt','w')file_temp.write(download(urllib2.quote("绿箭侠第三季第13集/Arrow.S03E13.720p.HDTV.X264-DIMENSION.chn")))出现问题:raiseInvalidURL("Invalidpercent-escapesequence:'%s'"%h)requests.exceptions.InvalidURL:Invalidpercent-escapesequence:'DI'检查之后去掉绿箭侠第三季第13集/Arrow.S03E13.720p.HDTV.X264-DIMENSION.chn中'DI'前面的-后报错消失.求教产生这种错误的原因,或者有什么比较好的替代方法,新人第一次提问,有什么问题大家指出,虚心接受大家的批评~
添加回答
举报
0/150
提交
取消