from fake_useragent import UserAgent
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
opts = Options()
ua = UserAgent()
some_width = 1024
some_height = 1024
opts.add_argument(f"user-agent={ua.chrome}")
opts.add_argument(f"--width={some_width}")
opts.add_argument(f"--height={some_height}")
...
driver = webdriver.Chrome(chrome_options=opts)
opts.add_argument("user-data-dir=/путь до кастомного профайла")
from lxml import etree
xml = '''ВАШ XML'''
parser = etree.XMLParser(
encoding='utf-8',
recover=True,
)
root = etree.fromstring(xml.encode(), parser=parser)
address = root.xpath('.//address')[0].get('addr')
cpe = root.xpath('.//cpe')
for im in cpe:
print(f'{address} : {im.text}')
print(f'{address} : {cpe[0].text}')
SELECT t1.telegram_id, t1.text, t2.text, t3.text, t4.text, t5.text
FROM first_table AS t1
LEFT JOIN second_table AS t2
ON t2.telegram_id = t1.telegram_id
LEFT JOIN third_table AS t3
ON t3.telegram_id = t1.telegram_id
LEFT JOIN forth_table AS t4
ON t4.telegram_id = t1.telegram_id
LEFT JOIN fifth_table AS t5
ON t5.telegram_id = t1.telegram_id
WHERE t1.telegram_id=<какой-то ID>
import requests
class SomeService:
def __init__(self, **my_params):
self.my_params = my_params
def some_action(self):
response = requests.get(SOMEURL, my_params)
return response.json()
>>> a = 'ddf%%21b#'
>>> b = '%%$ #'
>>>
>>>
>>> any([x.isdigit() or x.isalpha() for x in a])
True
>>> any([x.isdigit() or x.isalpha() for x in b])
False
>>>
>>> a = 'fgdf1'
>>> all([
any([x.isdigit() for x in a]),
any([x.isalpha() and x.islower() for x in a]),
any([x.isalpha() and x.isupper() for x in a])
])
False
>>> a = 'ssdS2'
True
>>> a = '4455'
False
>>> a = '4##sedfsdfD'
True
>>> import re
>>> bool(re.match('.*([a-z]|[A_Z]|[0-9]).*', ''))
False
>>> bool(re.match('.*([a-z]|[A_Z]|[0-9]).*', '$###@@*'))
False
>>> bool(re.match('.*([a-z]|[A_Z]|[0-9]).*', '$##e#@@*'))
True
>>> bool(re.match('.*([a-z]|[A_Z]|[0-9]).*', '$##34#@@*'))
True
>>>
import re
txt = '''{
"text": ":warning: OK - serv1: Service "TrustedInstaller" (Windows Modules Installer) is not running (startup type automatic)"
}'''
cleaned_dict = {}
for im in re.findall(r'\"(\w+)\": \"(.*)\"', txt):
cleaned_dict[im[0]] = im[1].replace('"', "'")
print(cleaned_dict)
...
if b>10:
print("Impulse outside the schedule")
exit() # <----- закомментировать или удалить или правильно отформатировать пробелами
def f(x):
if x<a:
...