Advertisement
Guest User

Soyscript

a guest
Jul 25th, 2022
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #HOW TO USE SOYSCRIPT.PY
  2.  
  3. #The first argument will specify the board. The second argument will specify the thread.
  4. #This will automatically generate a random soyspam for you to post in the thread.
  5. #The generated soyspam will be saved to soyspam.txt.
  6.  
  7. #You can probably modify this to make it work for other chans.
  8.  
  9. import sys
  10. import os
  11. import requests
  12. import json
  13. import re
  14. from random import shuffle
  15. import w3lib.html
  16.  
  17. r = requests.get('https://a.4cdn.org/'+sys.argv[1]+'/thread/'+sys.argv[2]+'.json')
  18. r = r.json()
  19.  
  20. posts = []
  21.  
  22. charrep = [
  23. ("\n","\n>"),
  24. ("'","'"),
  25. ("\","\\"),
  26. (">",">"),
  27. (""","\""),
  28. ("&lt;","<"),
  29. ("&nbsp;"," "),
  30. ("&cent;","¢"),
  31. ("&pound;","£"),
  32. ("&yen;","¥"),
  33. ("&euro;","€"),
  34. ("&copy;","©"),
  35. ("&reg;","®"),
  36. ("&amp;","&")
  37. ]
  38.  
  39. for p in r['posts']:
  40. try:
  41. com = p['com']
  42. if com.count('&gt;') > 16:
  43. continue
  44. com = com.replace('<br>','\n')
  45. com = w3lib.html.remove_tags(com)
  46. #com = replace_entities(com)
  47. for r in charrep:
  48. com = com.replace(r[0],r[1])
  49.  
  50. com = ">>"+str(p['no'])+"\n>"+com
  51. posts.append(com)
  52. except:
  53. continue
  54.  
  55. outtxt = ""
  56. shuffle(posts)
  57.  
  58. for p in posts:
  59. tempouttxt = outtxt + p + "\n\n"
  60. if len(tempouttxt) > 1999:
  61. continue
  62. elif tempouttxt.count("\n") > 99:
  63. continue
  64. else:
  65. outtxt = tempouttxt
  66.  
  67. out = open("soyspam.txt","w")
  68. out.write(outtxt)
  69. out.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement