Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_trans_res (urls: list) -> list:
res_list = []
reqs = (grequests.get(u, verify=True, allow_redirects=True, timeout=4, headers=headers) for u in urls)
res = grequests.map(reqs, size=20)
for r in res:
if hasattr(r, 'status_code'):
if r.status_code == 200:
try:
a = format_json(r.text)
target = ''.join([d[0] if d[0] else '' for d in a[0]])
source = ''.join([d[1] if d[1] else '' for d in a[0]])
except Exception as e:
source = ''
target = ''
if len(source) != 0 and len(target) != 0:
res_list.append(target)
else:
res_list.append('')
else:
res_list.append('')
return res_list