#๐Ÿ”’ merchant cleansing

7 messages ยท Page 1 of 1 (latest)

kind arrow
#

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

plain mistBOT
#

@kind arrow

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

scarlet sparrow
#

i'm guessing you installed a googlesearch module that has a similar name to the one you really wanted

#

there's of course also no guarantee that chatgpt gave you code that's correct for any search module...

plain mistBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.