Need help with this script

Joined
Mar 11, 2023
Messages
2
Reaction score
0
can anyone adjust this python script to run a set amount range on a specific serial and then move on to the next serial and do the same after printing the result ?





import requests

import os

try:

from anticaptchaofficial.recaptchav2proxyless import *

except:

os.system('python3 -m pip install anticaptchaofficial')

from anticaptchaofficial.recaptchav2proxyless import *









def get_g_response():

g_response = 0

solver = recaptchaV2Proxyless()

solver.set_verbose(0)

solver.set_key("79f5448cc70e9409b8c634134d2e1db3")

solver.set_website_url("https://tcvs.fiscal.treasury.gov/")

solver.set_website_key("6LdJmKEaAAAAAJ6A6SvD09PyyJAAFtYUQHb277lh")

#set optional custom parameter which Google made for their search page Recaptcha v2

#solver.set_data_s('"data-s" token from Google Search results "protection"')

solver.set_soft_id(0)

g_response = solver.solve_and_return_solution()

if g_response != 0:

return g_response

else:

print('failed getting response')

return False





def check_serial(serial, Date,Amount):

amount=

s=str(serial)

a= s

n=1

c = int(a) % int(n)

ck_digit= c

#amount=amount

date='2022-' + str(Date)

for x in amount:

print('CHECK #: ' + str(serial) + '['+ str(ck_digit) + ']' + 'AMOUNT' + x + ' ISSUE DATE: ' + str(date))

g_response = get_g_response()

if g_response:

headers = {

'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0',

'Accept': 'application/json, text/plain, */*',

'Accept-Language': 'en-US,en;q=0.5',

# 'Accept-Encoding': 'gzip, deflate, br',

'Referer': 'https://tcvs.fiscal.treasury.gov/',

'RecaptchaResponse': g_response,

'Connection': 'keep-alive',

# 'Cookie': 'TS0130273e=01f6e3b1e9de21a8bcbd805770e36f4fa256723cfe7cc999222e0d0374d0e0e887d487e8e08d20feb9d01a92639252651aa9cf9742',

'Sec-Fetch-Dest': 'empty',

'Sec-Fetch-Mode': 'cors',

'Sec-Fetch-Site': 'same-origin'}

cookies = {

'TS0130273e': '01f6e3b1e9de21a8bcbd805770e36f4fa256723cfe7cc999222e0d0374d0e0e887d487e8e08d20feb9d01a92639252651aa9cf9742',

}

params = {

'symbol_number': '4045',

'serial_number': str(serial),

'amount': amount,

'bank_rtn': '000000518',

'issue_date': str(date),

}

response = requests.get('https://tcvs.fiscal.treasury.gov/api/anon/validate', params=params, cookies=cookies, headers=headers)

r=response.text

print('RESULT = ' + str(r))

print('--------------------------------------------------------------------')

Paid = ('P') in r

Issued = ('I') in r

Null = ('null') in r

Cancelled = ('C') in r

ser=(str(serial))

c_file=open("checked.txt", 'r')

read_file = c_file. read()

if ser in read_file:

pass

elif ser not in read_file:

with open('checked.txt', 'a+') as checked_file:

checked_file.write(str(serial) + 'AMOUNT' + '\n' + str(date))

c_file.close()

if Null == True:
with open('NO_MATCH.txt', 'a+') as nomatch_file:

nomatch_file.write(str(serial) + '['+ str(ck_digit) + ']' + ' | IS NO MATCH FOR AMOUNT: ' + x + ' \n')

elif Paid == True:

with open('paid.txt', 'a+') as paid_file:

paid_file.write(str(serial) + '['+ str(ck_digit) + ']' + ' | ' + x[0:4] + ' | ' + str(date) + ' | PAID' + '\n')

break

elif Issued == True:

with open('Issued.txt', 'a+') as issued_file:

issued_file.write(str(serial) + '['+ str(ck_digit) + ']' + ' | ' + x[0:4] + ' | ' + str(date) + ' | ISSUED' + '\n')

break

elif Cancelled == True:

with open('cancelled.txt', 'a+') as cancelled_file:

cancelled_file.write(str(serial) + '['+ str(ck_digit) + ']' + ' | ' + str((r[18:31])) + '\n')


break






from time import sleep, perf_counter

import queue

import os





def run1():

file_exists = os.path.isfile('checked.txt')

if file_exists == False:

print('ENTER A SERIAL NUMBER TO CREATE FILE--ONLY NEED TO DO FOR 1ST TIME')

s= input('INPUT HERE: ' + ' → ')

print(' ')

print('ENTER DATE FOR ABOVE SERIAL: (MM-DD FORMAT) ' + ' FOR EXAMPLE: 10-18')

d= input('INPUT HERE: ' + '→ ')

print(' ')

with open('checked.txt', 'x') as checked_file:

checked_file.write(str(s) + ' | 2022-' + str(d) + '\n')

run1()

if file_exists == True:

f1 = open('checked.txt', 'r')

last_line = f1.readlines()[-1]

f1.close()

print(' ')

print('ENTER AMOUNTS BY 2 DIGITS ONLY------SEPERATE AMOUNTS BY COMMA')

print(' ')

Amounts = input('EXAMPLE: 14,28,42, etc. ' + '\n' + '→→')

amounts = Amounts.split(",")

List1 = amounts

string = ""

amount = list(map(lambda x:"{}{}".format(x, string), List1))

print(' ')

print('LAST NUMBER TO BE CHECKED WAS: ' + '\n' + '→→'+ last_line[0:8])

print(' ')

print('DO YOU WANT TO CONTINUE FROM THIS NUMBER?:' +'\n')

print(' ')

cont=input('YES OR NO? (CAN ENTER Y OR N):').lower()

print(' ')

if cont.startswith('n') == True:

serial_nm = (input('ENTER 8-DIGIT SERIAL # : ' + '\n'))

print('-----------------------------------------------------------------')

print(' ')

print('ENTER ISSUE DATE '+ ' (MM-DD FORMAT): ')

print(' ')

Date = input('EXAMPLE (10-18): ' + '\n' + '→→')

print(' ')

print('-----------------------------------------------------------------')

print(' ')

serial=serial_nm

elif cont.startswith('y') == True:

serial_nm = (last_line[0:8])

Date = (last_line[16:21])

serials=serial_nm

serial= (str(int(serials)+1))

print('-----------------------------------------------------------------')

print('ARE THESE ALL CORRECT?: ' )

print(' ')

print('SERIAL# = '+str(serial))

print(' ')

print('ISSUE DATE = 2022-'+str(Date))

print(' ')

print('AMOUNTS = ' +str(amount))

print(' ')

print('YES OR NO?')

print(' ')

Answer=input('TYPE Y OR N: ').lower()

print(' ')

print('-----------------------------------------------------------------')

print(' ')

q=queue.Queue()

if Answer.startswith('y') == True:

print(' ')

print('---------NOW CHECKING----------')

print('--NUMBER IN [ ] AFTER SERIAL NUMBER IS CHECK DIGIT--')

print(' ')

[q.put(str(int(serial)+x)) for x in range(500)]

for me in range(500):

serial=q.get()

check_serial(str(serial),str(Date),amount)

try:

driver.quit()

except:


pass

elif Answer.startswith('n') == True:

print('PLEASE RE-ENTER AND TRY AGAIN')

run1()




run1()
 
Joined
Mar 5, 2023
Messages
8
Reaction score
3
To run the script on a set amount range on a specific serial and move on to the next serial after printing the result, you need to make some changes in the `run1()` function. Here is the updated function:

Python:
def run1():
    # rest of the code here
    print('                                                      ')
    print('ENTER START SERIAL NUMBER TO CHECK: ')
    start_serial = input('INPUT HERE: ' + ' → ')
    print('                                                      ')
    print('ENTER END SERIAL NUMBER TO CHECK: ')
    end_serial = input('INPUT HERE: ' + ' → ')
    print('                                                      ')
  
    for serial_num in range(int(start_serial), int(end_serial)+1):
        serial = str(serial_num).zfill(8)
        print('CHECKING SERIAL NUMBER:', serial)
      
        # rest of the code here
Here we have added two input statements to input the start and end serial numbers to check. Then in the `for` loop, we are looping through a range of serial numbers between start and end serial numbers. We are using `.zfill(8)` to make sure that the serial number is of 8-digit length.

You can replace the existing `run1()` function with this updated function to run the script on a set amount range on a specific serial and then move on to the next serial after printing the result.
 
Joined
Dec 10, 2022
Messages
73
Reaction score
22
You should post code in the correct tags. Could you show what the expected output should be?
What is it that the script should do?
 
Joined
Mar 15, 2023
Messages
5
Reaction score
0
To run the script for a set amount range on a specific serial and move on to the next serial and do the same, you will need to add a loop that iterates over the list of serial numbers and the amount range for each serial number.

Here is an updated script that should accomplish this:

Python:
import requests
import os
from anticaptchaofficial.recaptchav2proxyless import *

def get_g_response():
    g_response = 0
    solver = recaptchaV2Proxyless()
    solver.set_verbose(0)
    solver.set_key("79f5448cc70e9409b8c634134d2e1db3")
    solver.set_website_url("https://tcvs.fiscal.treasury.gov/")
    solver.set_website_key("6LdJmKEaAAAAAJ6A6SvD09PyyJAAFtYUQHb277lh")
    solver.set_soft_id(0)
    g_response = solver.solve_and_return_solution()
    if g_response != 0:
        return g_response
    else:
        print('failed getting response')
        return False

def check_serial(serial, date, amount_range):
    s=str(serial)
    n=1
    c = int(s) % int(n)
    ck_digit= c
    for amount in amount_range:
        print('CHECK #: ' + str(serial) + '['+ str(ck_digit) + ']' + 'AMOUNT' + amount + ' ISSUE DATE: ' + str(date))
        g_response = get_g_response()
        if g_response:
            headers = {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0',
                'Accept': 'application/json, text/plain, */*',
                'Accept-Language': 'en-US,en;q=0.5',
                'Referer': 'https://tcvs.fiscal.treasury.gov/',
                'RecaptchaResponse': g_response,
                'Connection': 'keep-alive',
                'Sec-Fetch-Dest': 'empty',
                'Sec-Fetch-Mode': 'cors',
                'Sec-Fetch-Site': 'same-origin'
            }
            cookies = {
                'TS0130273e': '01f6e3b1e9de21a8bcbd805770e36f4fa256723cfe7cc999222e0d0374d0e0e887d487e8e08d20feb9d01a92639252651aa9cf9742'
            }
            params = {
                'symbol_number': '4045',
                'serial_number': str(serial),
                'amount': amount,
                'bank_rtn': '000000518',
                'issue_date': str(date),
            }
            response = requests.get('https://tcvs.fiscal.treasury.gov/api/anon/validate', params=params, cookies=cookies, headers=headers)
            r=response.text
            print('RESULT = ' + str(r))
            print('--------------------------------------------------------------------')
            Paid = ('P') in r
            Issued = ('I') in r
            Null = ('null') in r
            Cancelled = ('C') in r
            ser=(str(serial))
            c_file=open("checked.txt", 'r')
            read_file = c_file. read()
            if ser in read_file:
                pass
            elif ser not in read_file:
                with open('checked.txt', 'a+') as checked_file:
                    checked_file.write(str(serial) + 'AMOUNT' + '\n' + str
 
Joined
Mar 11, 2023
Messages
2
Reaction score
0
To run the script for a set amount range on a specific serial and move on to the next serial and do the same, you will need to add a loop that iterates over the list of serial numbers and the amount range for each serial number.

Here is an updated script that should accomplish this:

Python:
import requests
import os
from anticaptchaofficial.recaptchav2proxyless import *

def get_g_response():
    g_response = 0
    solver = recaptchaV2Proxyless()
    solver.set_verbose(0)
    solver.set_key("79f5448cc70e9409b8c634134d2e1db3")
    solver.set_website_url("https://tcvs.fiscal.treasury.gov/")
    solver.set_website_key("6LdJmKEaAAAAAJ6A6SvD09PyyJAAFtYUQHb277lh")
    solver.set_soft_id(0)
    g_response = solver.solve_and_return_solution()
    if g_response != 0:
        return g_response
    else:
        print('failed getting response')
        return False

def check_serial(serial, date, amount_range):
    s=str(serial)
    n=1
    c = int(s) % int(n)
    ck_digit= c
    for amount in amount_range:
        print('CHECK #: ' + str(serial) + '['+ str(ck_digit) + ']' + 'AMOUNT' + amount + ' ISSUE DATE: ' + str(date))
        g_response = get_g_response()
        if g_response:
            headers = {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0',
                'Accept': 'application/json, text/plain, */*',
                'Accept-Language': 'en-US,en;q=0.5',
                'Referer': 'https://tcvs.fiscal.treasury.gov/',
                'RecaptchaResponse': g_response,
                'Connection': 'keep-alive',
                'Sec-Fetch-Dest': 'empty',
                'Sec-Fetch-Mode': 'cors',
                'Sec-Fetch-Site': 'same-origin'
            }
            cookies = {
                'TS0130273e': '01f6e3b1e9de21a8bcbd805770e36f4fa256723cfe7cc999222e0d0374d0e0e887d487e8e08d20feb9d01a92639252651aa9cf9742'
            }
            params = {
                'symbol_number': '4045',
                'serial_number': str(serial),
                'amount': amount,
                'bank_rtn': '000000518',
                'issue_date': str(date),
            }
            response = requests.get('https://tcvs.fiscal.treasury.gov/api/anon/validate', params=params, cookies=cookies, headers=headers)
            r=response.text
            print('RESULT = ' + str(r))
            print('--------------------------------------------------------------------')
            Paid = ('P') in r
            Issued = ('I') in r
            Null = ('null') in r
            Cancelled = ('C') in r
            ser=(str(serial))
            c_file=open("checked.txt", 'r')
            read_file = c_file. read()
            if ser in read_file:
                pass
            elif ser not in read_file:
                with open('checked.txt', 'a+') as checked_file:
                    checked_file.write(str(serial) + 'AMOUNT' + '\n' + str
Much appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top