>>> def num_1():
... ...
...
>>> def num_2():
... ...
...
>>> num_1 + num_2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'function' and 'function'
>>> type(num_1)
<class 'function'>
>>> type(num_2)
<class 'function'>
def get_contact(ids):
for id in ids:
template = f'https://etender.gov.az/api/events/{id}/contact-persons'
try:
response = requests.get(template, timeout=20)
if response.status_code == 200:
data_list = response.json()
for data in data_list:
main_data['Full_name'].append(data.get('fullName', 'None') if data.get('fullName') else 'None')
main_data['Contact'].append(data.get('contact', 'None') if data.get('contact') else 'None')
main_data['Position'].append(data.get('position', 'None') if data.get('position') else 'None')
main_data['Phone_number'].append(data.get('phoneNumber', 'None') if data.get('phoneNumber') else 'None')
else:
main_data['Full_name'].append('None')
main_data['Contact'].append('None')
main_data['Position'].append('None')
main_data['Phone_number'].append('None')
except requests.Timeout:
main_data['Full_name'].append('None')
main_data['Contact'].append('None')
main_data['Position'].append('None')
main_data['Phone_number'].append('None')
main_data = []
...
def get_contact(ids):
for id in ids:
current_data = {'Full_name': 'None', 'Contact': 'None', 'Position': 'None', 'Phone_number': 'None'}
template = f'https://etender.gov.az/api/events/{id}/contact-persons'
try:
response = requests.get(template, timeout=20)
if response.status_code == 200:
data_list = response.json()
for (elem_to, elem_from) in [
('Full_name', 'fullName'),
('Contact', 'contact'),
('Position', 'position'),
('Phone_number', 'phoneNumber')
]:
current_data[elem_to] = data.get(elem_from, 'None')
except requests.Timeout:
pass
main_data.append(current_data)
scale_percent = 30
image = cv2.imread(captcha)
dim = (image.shape[1] * scale_percent // 100, image.shape[0] * scale_percent // 100)
resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
gray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY) #
ret, threshold_image = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)
threshold_image = np.invert(threshold_image)