Script for automated bitvisitor.com


SUBMITTED BY: Guest

DATE: March 9, 2014, 5:59 a.m.

FORMAT: Text only

SIZE: 7.6 kB

HITS: 935

  1. This script allows you to use bitvisitor.com without having to open it in a webbrowser.
  2. However, you will still have to wait the 5 minutes and enter the captchas manually.
  3. It is mainly a console application, but a small window will ask you for the captchas.
  4. This script was tested with Python 2.7 on Windows 7. Besides the standard stuff,
  5. it depends on BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/)
  6. and PIL (http://www.pythonware.com/products/pil/).
  7. usage: pyvisitor.py [-h] [-u path] [-a address] (all arguments are optional)
  8. optional arguments:
  9. -h, --help Show this help message and exit.
  10. -u path, --user-agents path A path to a file containing a user-agent on each line.
  11. -a address, --address address Your bitcoin address. If omitted, you will be prompted.
  12. Created on 02.01.2013
  13. Last update on 30.07.2013
  14. @author: The_Exile (http://www.reddit.com/user/the_exiled_one/)
  15. Feel free to drop me a coin or two at 13QgXZGtXYEY9cnEB9mGuD1ZbXMWirTicg
  16. '''
  17. from PIL import Image, ImageTk
  18. from Tkinter import Tk, Entry, Label
  19. from argparse import ArgumentParser
  20. from bs4 import BeautifulSoup
  21. from cStringIO import StringIO
  22. from cookielib import CookieJar
  23. from random import randrange, choice
  24. from time import sleep
  25. from urllib import urlencode
  26. from urllib2 import urlopen, Request, HTTPCookieProcessor, install_opener, build_opener, URLError
  27. class InputWindow:
  28. def __init__(self, container, img=None, p=None):
  29. root = Tk()
  30. root.attributes('-topmost', 1)
  31. hint = '(Enter - submit, Esc - abort)'
  32. if img is None:
  33. root.wm_title('Address')
  34. hint = 'Please enter your Bitcoin address.\n' + hint
  35. else:
  36. root.wm_title('Captcha {0:g}'.format(p))
  37. img = ImageTk.PhotoImage(img)
  38. root.img_reference = img
  39. image = Label(root, image=img, text=hint, compound='top')
  40. image.pack()
  41. entry = Entry(root)
  42. entry.bind('<Escape>', lambda _:root.destroy())
  43. entry.bind('<Return>', lambda _:(container.setdefault(0, (entry.get())), root.destroy()))
  44. entry.pack()
  45. entry.focus_set()
  46. root.update_idletasks()
  47. xp = (root.winfo_screenwidth() / 2) - (root.winfo_width() / 2) - 8
  48. yp = (root.winfo_screenheight() / 2) - (root.winfo_height() / 2) - 20
  49. root.geometry('+%d+%d' % (xp, yp))
  50. root.mainloop()
  51. class PyVisitor:
  52. def __init__(self, address=None, agentFile=None):
  53. self.__addr = address
  54. if not address:
  55. address = {}
  56. InputWindow(address)
  57. if not address.get(0):
  58. print 'Aborted by user.'
  59. exit(0)
  60. self.__addr = address[0]
  61. self.__currentProfit = .0
  62. self.__currency = ''
  63. self.__captchaURL = None
  64. self.__host = 'http://bitvisitor.com/'
  65. defaultAgent = 'Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.15'
  66. self.__headers = {'Accept':'text/html,application/xhtml+xml,application/xml',
  67. 'User-Agent':defaultAgent}
  68. install_opener(build_opener(HTTPCookieProcessor(CookieJar())))
  69. if agentFile:
  70. try:
  71. with open(agentFile) as f:
  72. self.__headers['User-Agent'] = choice([agent.rstrip() for agent in f])
  73. except:
  74. print 'Using default User-Agent.'
  75. print 'User-Agent:', self.__headers['User-Agent']
  76. print 'Bitcoin address:', self.__addr
  77. def __getCaptchaURL(self, soup):
  78. captchaImg = soup.find('img', id='siimage')
  79. if not captchaImg:
  80. return
  81. earning = soup.find('h1', 'page-header').contents[1].split()
  82. self.__currentProfit = float(earning[0])
  83. self.__currency = earning[1]
  84. self.__captchaURL = self.__host + captchaImg['src'].lstrip('./')
  85. return self.__captchaURL
  86. def __wait(self, soup):
  87. siteFrame = soup.find('iframe', id='mlsFrame')
  88. if not siteFrame: return
  89. print 'Visiting', siteFrame['src']
  90. print 'Getting {0:g} {1} in'.format(self.__currentProfit, self.__currency),
  91. for i in range(5, 0, -1):
  92. print i,
  93. sleep(60)
  94. print
  95. sleep(randrange(1, 10)) # just to be sure ;)
  96. def visit(self):
  97. req = Request(self.__host, None, self.__headers)
  98. res = urlopen(req) # set session cookie
  99. if 'abuse' in res.geturl():
  100. print 'ERROR: The IP address was deemed suspicious.'
  101. return
  102. # Please do not change the address in the next line. It costs you nothing, but it helps me.
  103. params = urlencode({'addr':self.__addr, 'ref':'1Mj8JCYJDjDKMjmvsTrpVPap4BvFyGZVCm'})
  104. url = self.__host + 'next.php'
  105. self.__headers['Referer'] = url
  106. req = Request(url, params, self.__headers)
  107. while True:
  108. res = urlopen(req)
  109. if 'abuse' in res.geturl():
  110. print 'ERROR: The IP address was deemed suspicious.'
  111. break
  112. soup = BeautifulSoup(res.read())
  113. if not self.__getCaptchaURL(soup): break
  114. a = None
  115. while not a:
  116. captcha = {}
  117. InputWindow(captcha, Image.open(StringIO(urlopen(self.__captchaURL).read())), self.__currentProfit)
  118. if not captcha.get(0):
  119. print 'Aborted by user.'
  120. break
  121. cParams = urlencode({'ct_captcha':captcha[0], 'addr':self.__addr})
  122. soup = BeautifulSoup(urlopen(Request(url, cParams, self.__headers)).read())
  123. form = soup.find('form', action='next.php')
  124. if not form:
  125. message = soup.get_text()
  126. if 'Incorrect' in message: continue
  127. print message
  128. break
  129. a = form.find('input', {'name':'a'})['value']
  130. t = form.find('input', {'name':'t'})['value']
  131. if a and t:
  132. break
  133. if not a: # aborted by user or site error
  134. break
  135. self.__wait(soup)
  136. nParams = urlencode({'addr':self.__addr, 'a':a, 't':t})
  137. res = urlopen(Request(url, nParams, self.__headers))
  138. if not res:
  139. break
  140. print 'Earned {0:g} {1}'.format(self.__currentProfit, self.__currency)
  141. def main():
  142. parser = ArgumentParser()
  143. parser.add_argument('-u', '--user-agents', metavar='path',
  144. help='A path to a file containing a user-agent on each line.')
  145. parser.add_argument('-a', '--address', metavar='address',
  146. help='Your bitcoin address. If omitted, you will be prompted.')
  147. ns = parser.parse_args()
  148. try:
  149. PyVisitor(ns.address, ns.user_agents).visit()
  150. except URLError as e:
  151. print str(e)
  152. if __name__ == "__main__":
  153. main()

comments powered by Disqus