Bitvisitor python script


SUBMITTED BY: Guest

DATE: Nov. 17, 2013, 2:10 p.m.

FORMAT: Text only

SIZE: 7.6 kB

HITS: 10685

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

comments powered by Disqus