#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 27 12:05:19 2020

@author: lewis
"""

from sys import argv
from Bio import Entrez

Entrez.email = 'lewis@fbb.msu.ru'

txtterm = argv[1]

shandle = Entrez.esearch(db='nucleotide', term=txtterm, idtype='acc', retmax='5')
ressearch = Entrez.read(shandle)

for ac in ressearch['IdList']:
    handle = Entrez.efetch(db='nucleotide', term="query", idtype='acc', id=ac, rettype="gb", retmode="text")
    print(handle.read())
    handle.close()
    print('-------------------------------')