I am currently writing a programme using Biopython and part of it involves searching Pubmed using an entry specified by the user. This returns all the records that match this entry. I then want to search just these records for a specific author, again specified by the user, however I am having issues with how to do this. If anyone can help, it would be much appreciated.
Here is my code so far, it is largely taken from the Biopython cookbook documentation. For this example, I am searching for the word "brainbow" and the author "Currie" (which I believe should be there).
from Bio import Entrez, SeqIO, Medline Entrez.email = "A.N.Other@example.com" def pbmd_search(): #searches pubmed database, using Biopython documentation handle = Entrez.egquery(term="brainbow") record = Entrez.read(handle) for row in record["eGQueryResult"]: if row["DbName"]=="pubmed": print(str(row["Count"]) + " records returned") handle = Entrez.esearch(db="pubmed", term="brainbow", retmax=1000) record = Entrez.read(handle) idlist = record["IdList"] handle = Entrez.efetch(db="pubmed", id=idlist, rettype="medline", retmode="text") records = Medline.parse(handle) records = list(records) records_str =  for record in records: records_str += "Title: %s \nAuthors: %s \nSource: %s\n\n" %(record.get("TI"), ", ".join(record.get("AU")), record.get("SO")) search_author = "Currie" print(search_author) if search_author in records_str: print("yes") else: print("no")