init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/test
|
||||||
|
test.txt
|
||||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
requests
|
||||||
|
argparse
|
||||||
|
Pillow
|
||||||
|
ffmpeg-python
|
||||||
52
scrapechan.py
Normal file
52
scrapechan.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import requests, json, time, argparse, sys, os, ffmpeg
|
||||||
|
from PIL import Image
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-u', type=str, required=True)
|
||||||
|
parser.add_argument('-o', type=str, required=True)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
r = requests.get(args.u + ".json")
|
||||||
|
|
||||||
|
print("Got main request")
|
||||||
|
|
||||||
|
rjson = r.json()
|
||||||
|
|
||||||
|
board = args.u.split("/")[3]
|
||||||
|
|
||||||
|
for i in rjson['posts']:
|
||||||
|
if "ext" in i:
|
||||||
|
ir = requests.get("https://i.4cdn.org/" + board + "/" + str(i['tim']) + i['ext'])
|
||||||
|
|
||||||
|
print("Got post request")
|
||||||
|
|
||||||
|
bstream = BytesIO(ir.content)
|
||||||
|
|
||||||
|
try:
|
||||||
|
ir = requests.get("https://i.4cdn.org/" + board + "/" + str(i['tim']) + i['ext'])
|
||||||
|
im = Image.open(bstream)
|
||||||
|
print("Converted bytes to image")
|
||||||
|
im.save(args.o + "/" + str(i['tim']) + i['ext'])
|
||||||
|
print("Saved image")
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('Closing')
|
||||||
|
try:
|
||||||
|
sys.exit(130)
|
||||||
|
except SystemExit:
|
||||||
|
os._exit(130)
|
||||||
|
except:
|
||||||
|
print("Cant convert data to image maybe not an image format")
|
||||||
|
print("NO:" + str(i['no']))
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
ffmpeg.input(bstream).output(args.o + "/" + str(i['tim']) + ".mp4").run()
|
||||||
|
print("Saved video")
|
||||||
|
except:
|
||||||
|
print("Cant convert to Video")
|
||||||
|
"""
|
||||||
|
|
||||||
|
print("Done!!")
|
||||||
Reference in New Issue
Block a user