Guest User

4chan-countries-scrape.fish

a guest
Apr 23rd, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/usr/bin/fish
  2.  
  3. mkdir pol-threads
  4. pushd pol-threads
  5. curl https://a.4cdn.org/pol/catalog.json > catalog.json
  6. for value in (cat catalog.json | jq ".[].threads|.[]|.no")
  7. curl "https://a.4cdn.org/pol/thread/$value.json" > "$value.json"
  8. end
  9.  
  10. for jfile in 3*.json; cat "$jfile" | jq ".posts|.[]|.country_name"; end | sort | uniq > countries.txt
  11.  
  12. cat countries.txt
  13. cat countries.txt | wc -l
  14. # 100
  15.  
  16. popd
  17.  
  18. mkdir int-threads
  19. pushd int-threads
  20.  
  21. curl https://a.4cdn.org/int/catalog.json > catalog.json
  22. for value in (cat catalog.json | jq ".[].threads|.[]|.no")
  23. curl "https://a.4cdn.org/int/thread/$value.json" > "$value.json"
  24. end
  25.  
  26. for jfile in 3*.json; cat "$jfile" | jq ".posts|.[]|.country_name"; end | sort | uniq > countries.txt
  27.  
  28. cat countries.txt
  29. cat countries.txt | wc -l
  30.  
  31. popd
  32.  
  33.  
Advertisement
Add Comment
Please, Sign In to add comment