最近,我在使用履带机时遇到了一个非常奇怪的bug。我的剧本几乎适用于每一种情况。但是,当我试图执行压力测试(比如爬行1000组数据)时,我保存为.torrent
的大多数数据都没有错误,但其中一个数据返回错误。这是剧本。
temp=torrent_title
temp=temp[0:246:1]#maximum length of file name in win10
for tempa in range(len(temp)):
if(temp[tempa] in '\/:*?"<>|'):#special word that can't be named the name of a file in win10
temp=temp.replace(temp[tempa]," ")
r=requests.get(url)
filename=temp+".torrent"
while(not r.status_code==requests.codes.ok):
r = requests.get(url, allow_redirects=True)
open(download_path+"\\"+filename, 'wb').write(r.content)
和错误
line 119, in main
open(download_path+"\\"+filename, 'wb').write(r.content)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\C147\\Downloads\\sukebei-crawler-v2-master\\sukebei-crawler-v2-master\\div\\downloads\\08-04-2021_16-35-09\\+++ [HD] 459TEN-016 【性獣危険】Fカップ現役女子大生の自宅に突撃!!とっておきの勝負下着で悩殺ファック!!『人類みなセフレ』!!触れる者みなSEXするとんでもない性獣を捕まえてしまいました!!完全にコントロール不可能のバーサーカービッチにデカチン3人を投入して無限絶頂させまくる!!!イラマと無限ピストンで快楽のその向こう側へ…【性豪ギャル自宅中出し】勝負下着、見せちゃいます!vol.13.torrent'
顺便说一下,这个脚本是在win10上执行的。
发布于 2021-04-08 16:06:55
我自己找到答案。只要将编码=‘utf-8-sig’添加到open(),它就可以在win10上正常工作。
https://stackoverflow.com/questions/67007487
复制相似问题