Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this script goes into the same directory as scan-wallets.py&process-claims.py&login.py&satoshi.py&claim.py&WalletsNew.txt&Proxies.txt
- import requests
- import time
- import os
- import sys
- import pickle
- from pyquery import PyQuery
- def load_cookies(filename):
- with open(filename, 'rb') as f:
- return pickle.load(f)
- def randomUA():
- UserAgents = ['Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0']
- return UserAgents[0]
- BitcoinAddress = sys.argv[1]
- claimUrl = 'http://www.5minbitcoin.com/index.php?cmd=claim'
- ProxyTestPayload = 'http://secure.gaug.es/track.js'
- # Load the Captcha Code file
- try:
- CaptchaFile = open('Captcha_' + BitcoinAddress + '.txt', 'r')
- CaptchaCode = CaptchaFile.read()
- CaptchaFile.close()
- # If we got this far without an error, and there's a JPG file for the Wallet address, we need to get rid of it
- try:
- os.remove('Captcha_' + BitcoinAddress + '.jpg')
- except:
- # Doesn't exist or it's already been removed
- pass
- except:
- pass
- # Load Proxy data
- ProxyAddress = open(BitcoinAddress + '.proxy', 'r')
- ProxyData = ProxyAddress.read()
- Proxy = {'http': 'http://' + ProxyData,}
- ProxyAddress.close()
- # Load Header data
- H = open(BitcoinAddress + '.headers', 'r')
- Headers = H.read()
- H.close()
- def Claim():
- try:
- s = requests.session()
- s.headers = Headers
- thisSession = s.post(claimUrl, cookies=load_cookies(BitcoinAddress + '.cookie'), data = {'captcha': CaptchaCode}, proxies=Proxy)
- responseData = thisSession.content
- #print responseData
- if(CheckIdiotProxyResponse == 'idiot'):
- # Got an idiot response - try another proxy
- os.remove('Captcha_' + BitcoinAddress + '.txt')
- os.remove(BitcoinAddress + '.proxy')
- os.remove(BitcoinAddress + '.cookie')
- return
- # Verify the response data to make sure it's not a random proxy error message
- if(responseData.find('Satoshi') > -1):
- pass
- else:
- print BitcoinAddress + ' Proxy Error'
- #print responseData
- os.remove('Captcha_' + BitcoinAddress + '.txt')
- os.remove(BitcoinAddress + '.proxy')
- os.remove(BitcoinAddress + '.cookie')
- # sometimes the wallet address gets logged out need to relogin with the same proxy and then retry to claim on the next cycle
- # look for "cmd=login" in the HTML response
- if(responseData.find('cmd=login') > -1):
- print BitcoiinAddress + ': -' + 'need login'
- p = open('Proxy.pool', 'a')
- p.write( ProxyData + '\n')
- p.close()
- os.remove(BitcoinAddress + '.proxy')
- os.remove(BitcoinAddress + '.cookie')
- os.remove(BitcoinAddress + '.headers')
- os.remove('Captcha_' + BitcoinAddress + '.txt')
- if(responseData.find('captcha/captcha.php') > -1):
- # Delete the Captcha Txt, Cookies, and Proxy file for that wallet address
- print BitcoinAddress + ' - need cookie reauth'
- os.remove('Captcha_' + BitcoinAddress + '.txt')
- f = open(BitcoinAddress + '.proxy', 'r')
- BackupProxy = f.read()
- f.close()
- f = open('ProxyBackups', 'a')
- f.write(BackupProxy + '\n')
- f.close()
- os.remove(BitcoinAddress + '.proxy')
- os.remove(BitcoinAddress + '.cookie')
- os.remove(BitcoinAddress + '.headers')
- else:
- # Parse out the Satoshi balance left to be claimed as well as the time since the last Claim
- html = responseData
- pq = PyQuery(html)
- tag = pq('a')
- SatoshiText = tag.text()
- SatoshiBalance = SatoshiText.split(' ')
- # Get the Satoshi account balance
- balance = open(BitcoinAddress + '.sat', 'w')
- # Make sure the satoshi balance is greater than zero
- #print html
- try:
- if(len(SatoshiBalance[7]) > 0):
- balance.write(SatoshiBalance[7])
- print BitcoinAddress + ' - ' + SatoshiBalance[7]
- except:
- # Length of satoshi balance array is off somehow
- #print SatoshiBalance
- #print ''
- #print html
- pass
- except Exception as e:
- #pass
- print BitcoinAddress + ': - ' + 'exception'
- #if(responseData.find('squid') > -1):
- # print BitcoinAddress + ' - ' + 'Timeout Error' #str(e)
- # Failed too many times - axe it
- #os.remove('Captcha_' + BitcoinAddress + '.txt')
- #os.remove(BitcoinAddress + '.proxy')
- #os.remove(BitcoinAddress + '.cookie')
- #os.remove(BitcoinAddress + '.headers')
- def CheckIdiotProxyResponse(responseData):
- Rejected = ['Attention Required!', 'Access Denied', 'No DNS records', 'DNS resolving failed', 'ERROR', 'Privoxy']
- for y in range(len(Rejected) -1):
- if(responseData.find(Rejected[y]) > -1):
- # The proxy is rejecting the request - better try a new one
- return 'idiot'
- Claim()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement