from scholarly import scholarly import time import datetime def get_total_citations(query): total_citations = 0 count = 0 try: # Search for publications matching the query search_query = scholarly.search_pubs(query) while True: try: pub = next(search_query) title = pub.get('bib', {}).get('title', 'No title available') citations = pub.get('num_citations', 0) total_citations += citations count += 1 # Print the title and citations for each paper #print(f"Paper {count}:") #print(f" Title: {title}") #print(f" Citations: {citations}") #print(f" Total citations so far: {total_citations}\n") print(f"Citations: {citations:3d}. Title: {title}.") # Delay to avoid overwhelming the server time.sleep(5) except StopIteration: # No more results break except Exception as e: print(f"Error encountered: {e}") break except Exception as e: print(f"Search failed: {e}") return count, total_citations if __name__ == "__main__": now = datetime.datetime.now() print("Updated ", now.strftime("%Y-%m-%d %H:%M:%S")) #query = 'source:"klsjdfa"' #query = 'source:"OpenFOAM Journal"' query = 'source:"CFD with OpenSource Software"' print(f"Searching for papers from {query}...") nPapers, total = get_total_citations(query) print(f"\nNumber of papers: {nPapers}") print(f"\nTotal citations for all papers from {query}: {total}")