123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- from selenium import webdriver
- from selenium.webdriver import ChromeOptions
- # from selenium.webdriver.common.keys import Keys
- from time import sleep
- # from captcha_solver import CaptchaSolver
- from receipt import Receipts
- # from PIL import Image
- # from subprocess import check_output
- from datetime import date, datetime, timedelta
- import platform as pt
- # import pyautogui as ag
- # import pytesseract
- import os
- if pt.system() == 'Linux':
- cache_folder = '/home/deeejas/_sel_cache_/'
- else:
- cache_folder = 'c:/_sel_cache_/'
- # solver = CaptchaSolver('browser')
- # receipts = Receipts()
- chrome_options = ChromeOptions()
- prefs = {"profile.default_content_setting_values.notifications": 2}
- chrome_options.add_experimental_option("prefs", prefs)
- chrome_options.add_argument('--disable-infobars')
- chrome_options.add_argument('user-data-dir={0}'.format(cache_folder))
- driver = webdriver.Chrome(chrome_options=chrome_options)
- class MyReceipts(Receipts):
- def __init__(self):
- self.url = 'https://www.anaf.ro/StareD112/ObtineRecipisa?numefisier='
- def r_downloader(self, _ext='.pdf', cond1=4, cond2=6):
- # Receipts.r_downloader(self, _ext, cond1=cond1, cond2=cond2)
- my_path = os.getcwd().split('\\')[-1:]
- print('my_path', my_path)
- my_month = datetime.today() - timedelta(days=datetime.today().day)
- date_l = []
- if date.today().month < 10:
- date_l.append('%s 0%s' % (date.today().year, my_month.month))
- else:
- date_l.append('%s %s' % (date.today().year, my_month.month))
- print('date_l', date_l)
- sel = input('type c for current month or s to select month')
- mth_yr = '%s-%s' % (date(1900, my_month.month, 28).strftime('%b'), date.today().year)
- print('mth_yr', mth_yr)
- if sel == 'c':
- if my_path == date_l:
- for i, k in self.cond_range(cond1, cond2):
- if i != '' and k == mth_yr:
- driver.get(self.url + i + _ext)
- sleep(3)
- elif sel == 's':
- m = input('Mmm-YYY')
- for i, k in self.cond_range(cond1, cond2):
- if i != '' and k == m:
- driver.get(self.url + i + _ext)
- sleep(3)
- receipts = MyReceipts()
- receipts.get_gspread('Pygsheet-4a83fcaf2282.json', 'Recipisa-2019')
- driver.get('https://www.anaf.ro/StareD112/')
- input('send captcha, press enter')
- receipts.r_downloader(cond1=4, cond2=6)
- sleep(300)
- driver.close()
- # pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract-OCR/tesseract.exe"
- # print(pytesseract.image_to_string('captcha.png', output_type='data.frame'))
- # ag.screenshot('captcha.png', region=(0, 0, 974, 1057))
- # raw_data = open('captcha.png', 'rb').read()
- # print(solver.solve_captcha(raw_data))
|