Hack Forums
[Python] Invision Power Board View Bot - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Invision Power Board View Bot (/showthread.php?tid=5054633)



Invision Power Board View Bot - Baba Yaga - Nov 11, 2015

So I wanted to increase the view count on one of my posts in a forum run by some people I knew. Rather than do it manually, I decided to write a bot in Python. It was written for IPB4, but I am not sure if it is backwards compatible or not depending on whether the HTML code matches up. Anyways here it is...

https :// ghostbin . com /paste/bsjos (remove spaces, I don't have enough post count)

I want to ask the community this:
  • How can I make this a multi-threaded script so it can send more responses at one time
  • Any further optimizations to the code, and if so, please post your new and improved source code

There are several requirements for the script to run. You need to have the following:
  • Selenium module installed ($ sudo easy_install Selenium)
  • BeautifulSoup module installed ($ sudo easy_install BeautifulSoup4)
  • Python 2.7
  • Firefox browser

Here are the following lines you need to edit to make the script work for you:

PHP Code

<?php 
url 
= "https  :// crackyoass . com/index . php?/topic/146-list-of-scripts/" 

Change that to whatever post on the forum you want to boost

PHP Code

<?php 
browser
.get("https ://  crackyoass . com/index . php?/login/") 

Change that to the login pages

The usage is as follows: python ViewBot.py username password


* - goshmulticoloredalto - Nov 11, 2015

For the lazy people: https://ghostbin.com/paste/bsjos


* - Baba Yaga - Nov 12, 2015

Thank you 🙂

Also, do you know how to make the script multithreaded? Haven't tried my hand at that yet and Im not really sure how to implement it


* - SavageBoys - Nov 12, 2015

(Nov 11, 2015 05:45 PM)SwagMeister1337 Wrote:  I want to ask the community this:
  • How can I make this a multi-threaded script so it can send more responses at one time
  • Any further optimizations to the code, and if so, please post your new and improved source code

Haven't taken a good look at it yet but off the bat I know you could use asyncio and aiohttp to do just that.

Here is some garbage code I never got around to finishing that uses it:
PHP Code

<?php 
import lxml
.html
import asyncio
import aiohttp


@asyncio.coroutine
def get
(*args, **kwargs):
    
response = yield from aiohttp.request('GET', *args, **kwargs)
    return (yield from 
response.read_and_close())

def first_link(page):
    
fragment = lxml.html.fromstring(page)
    
path = fragment.xpath('//div[@class="data"]')
    return 
path

@asyncio.coroutine
def print_link
(query):
    
with (yield from sem):
        
page = yield from get(query, compress=True)
    
link = first_link(page)
    print(
'Coub: {} // Track: {}'.format(query, link))

links = ['http://coub.com/view/8jcbd']
sem = asyncio.Semaphore(5)
loop = asyncio.get_event_loop()
f = asyncio.wait([print_link(d) for d in links])
loop.run_until_complete(f) 
Was going to be a simple way to rip MP3s from coub (the links are buried in JSON embedded in the HTML)


* - Natecat33 - Nov 14, 2015

(Nov 12, 2015 12:35 PM)SwagMeister1337 Wrote:  Thank you 🙂

Also, do you know how to make the script multithreaded? Haven't tried my hand at that yet and Im not really sure how to implement it

No need to multithread, python doesn't give you any speed improvement from multithreading because it is all internally one thread, you only use multithreading when you actually need multiple threads running concurrently, like in a server