55ADVERT_URL_BN='https://bn.ua/prodaja-5-dom-k'
66ADVERT_WHITE_BN='Купить дом'
77ADVERT_BLACK_BN='404'
8- ADVERT_URL_KRYSHA=https://metry.ua/romankov/novoo
9- ADVERT_WHITE_KRYSHA='Продаж Будинку Голубе озеро'
8+
9+ ADVERT_URL_KRYSHA=https://metry.ua/novoo
10+ ADVERT_WHITE_KRYSHA='Продажа Озеро'
1011ADVERT_BLACK_KRYSHA=''
1112```
1213"""
2324# Suppress only the InsecureRequestWarning
2425warnings .simplefilter ('ignore' , InsecureRequestWarning )
2526
26- def parse_variables (file_path : str ) -> Tuple [Dict [str , str ], Dict [str , str ], Dict [str , str ]]:
27+ def parse_variables (file_path : str ) -> Tuple [Dict [str , str ], Dict [str , str ], Dict [str , str ], Dict [ str , str ] ]:
2728 dict_url :Dict [str ] = dict ()
2829 dict_white :Dict [str ] = dict ()
2930 dict_black :Dict [str ] = dict ()
31+ dict_keepass :Dict [str ] = dict ()
3032
3133 with open (file_path ) as f :
3234 for each_line in f .readlines ():
35+ each_line = each_line .strip ()
3336 if each_line .startswith ("ADVERT" ):
3437 position_equals :int = each_line .find ('=' )
3538 position_underscore :int = each_line .find ('_' , 8 )
@@ -42,7 +45,9 @@ def parse_variables(file_path: str) -> Tuple[Dict[str, str], Dict[str, str], Dic
4245 dict_black [name ]= each_line .strip ()[position_equals + 1 :].strip ("'" )
4346 if each_line .startswith ("ADVERT_URL" ):
4447 dict_url [name ]= each_line .strip ()[position_equals + 1 :].strip ("'" )
45- return dict_url , dict_white , dict_black
48+ if each_line .startswith ("ADVERT_KEEPASS" ):
49+ dict_keepass [name ]= each_line .strip ()[position_equals + 1 :].strip ("'" )
50+ return dict_url , dict_white , dict_black , dict_keepass
4651
4752def fetch_and_check_url (url : str , white : str , black : str ) -> bool :
4853 headers = {
@@ -52,17 +57,18 @@ def fetch_and_check_url(url: str, white: str, black: str) -> bool:
5257
5358 try :
5459 # Send the GET request with the headers
55- response = requests .get (url , headers = headers , verify = False , allow_redirects = True )
56-
60+ response = requests .get (url , headers = headers , verify = False , allow_redirects = True )
5761 # Check if the request was successful
5862 if 200 <= response .status_code < 300 :
63+ if black != '' :
64+ for each_black in black .split (';' ):
65+ if each_black in response .text :
66+ return False
5967 if white in response .text :
6068 return True
61- if black in response .text :
62- return False
6369
6470 # print("no options")
65- return False
71+ return False
6672 else :
6773 # print(f"Request failed with status code: {response.status_code}")
6874 return False
@@ -79,12 +85,19 @@ def fetch_and_check_url(url: str, white: str, black: str) -> bool:
7985 # file_path='/Dropbox/Dropbox/house-site/adverts.md'
8086 file_path = sys .argv [1 ]
8187
82- dict_url , dict_white , dict_black = parse_variables (file_path )
88+ dict_url , dict_white , dict_black , dict_keepass = parse_variables (file_path )
8389 keys = dict_url .keys ()
8490
91+ false_results_counter : int = 0
8592 for name in keys :
8693 result = fetch_and_check_url (dict_url [name ], dict_white [name ], dict_black [name ])
8794 if result :
8895 print (f"{ GREEN } { name } { dict_url [name ]} :\n { result } { RESET } " )
8996 else :
90- print (f"{ RED } { name } { dict_url [name ]} :\n { result } { RESET } " )
97+ print (f"{ RED } { name } { dict_url [name ]} :\n check advert: { dict_keepass [name ]} { RESET } " )
98+ false_results_counter += 1
99+ if false_results_counter > 0 :
100+ print ("" )
101+ print ("keepass-tech-get-url-clipboard " )
102+ print ("keepass-tech-get-user-clipboard " )
103+ print ("keepass-tech-get-pass-clipboard " )
0 commit comments