Advertisement
Guest User

Untitled

a guest
Feb 20th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # coding: utf8
  2. # image must be 920 x 780
  3.  
  4. import time
  5. import sys
  6. import re
  7. import StringIO
  8.  
  9. import requests
  10. import Image
  11.  
  12. coords = (
  13.    ((0, 0, 200, 200),
  14.     (240, 0, 440, 200),
  15.     (480, 0, 680, 200),
  16.     (720, 0, 920, 200)),
  17.    ((0, 290, 200, 490),
  18.     (240, 290, 440, 490),
  19.     (480, 290, 680, 490),
  20.     (720, 290, 920, 490)),
  21.    ((0, 580, 200, 780),
  22.     (240, 580, 440, 780),
  23.     (480, 580, 680, 780),
  24.     (720, 580, 920, 780))
  25. )
  26.  
  27. _, threadlink, imgpath = sys.argv
  28. board, thread = re.findall("/(\w+)/res/(\d+).html", threadlink)[0]
  29. im = Image.open(imgpath)
  30.  
  31. data = {
  32. 'task': 'post',
  33. 'board': board,
  34. 'thread': thread,
  35. }
  36.  
  37. for i in range(3):
  38.     files = {}
  39.     for x in range(4):
  40.         im.crop(coords[i][x]).save('D:\\1.jpg')
  41.         files['image{}'.format(x + 1)] = open('D:\\1.jpg', 'rb').read()
  42.     response = requests.post('https://2ch.hk/makaba/posting.fcgi', data=data,  files=files)
  43.     print response.status_code
  44.     time.sleep(20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement