so i have an excel sheet with over 27,000 rows of beneficiary merchant names
my task is to manually google search and find out the merchant name, logo, country, city, longitude, and latitude.
i dont know how to code in python so i used chatgpt to help me find a fast and accurate solution but this is the code that i ran:
import pandas as pd
from googlesearch import search
# Load the Excel file into a pandas DataFrame
df = pd.read_excel('your_excel_file.xlsx')
# Assuming the values are in the second column (index 1)
merchant_names = df.iloc[:, 1].tolist()
# Function to search Google and return the URL of the best result
def search_google(merchant_name):
query = f"{merchant_name} logo"
try:
for url in search(query, num=1, stop=1, pause=2):
return url
except Exception as e:
print(f"Error occurred while searching for {merchant_name}: {e}")
return None
# Dictionary to store merchant names and their corresponding URLs
merchant_urls = {}
# Iterate over merchant names and search Google for each
for name in merchant_names:
url = search_google(name)
if url:
merchant_urls[name] = url
# Print the results
for name, url in merchant_urls.items():
print(f"Merchant: {name} | URL: {url}")
the code runs but im not getting the results i want, this is an example:
Error occurred while searching for Azhar Wadi Al Mawal: search() got an unexpected keyword argument 'num'
i want a better code thats actually accurate, help pls