fork download
  1. def getALL():
  2. getURLs()
  3. for thread_title, dat in zip(title, url):
  4. print(thread_title,dat)#スレタイとURL
  5.  
  6. subject = dat
  7. request = urllib.request.Request(url=subject, headers=headers)#datとheaderのデータを入れる
  8.  
  9. with urllib.request.urlopen(request) as nep:#withを使うことでcloseを省略,接続
  10. text = nep.read().decode('cp932')#datファイル読み込み。cp932?
  11. lines = text.splitlines()
  12.  
  13. print(lines[0])#期待している出力値はdatファイルの>>1のデータ全て
  14. #実際に出力されるのは、>>1の1文字目だけ→「以」下、名無しに代わりまして...
  15.  
  16. #ファイルの書き込み
  17. #with open('./hisshi.txt','w') as file:
  18. with open('./'+str(ID)+'.txt','a') as file:
  19. #ここに文字列検索を入れる。もし、IDが見つかったら、スレタイとURLを記載する。textからIDが見つかったら、記入、改行する。
  20. if ID in lines:#if ID in text
  21. file.write(thread_title)
  22. file.write(dat+str('\n'))
  23. file.write(lines)#file.write(text)
  24. print(lines)#print(text)
  25. file.write(str('\n'))
Runtime error #stdin #stdout #stderr 0.01s 27712KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
  File "./prog.py", line 11
    lines = text.splitlines()
                            ^
TabError: inconsistent use of tabs and spaces in indentation