Script to open multiple Chrome tabs for a list of urls present in an Excel sheet

Rahil Shaikh

I have a list of (keywords) stored in a Column in an Excel Sheet, I want to open each keyword in different chrome tabs(multiple tabs) at once. Can anyone please help me with a python code to automate it?

P.S. I am not technically sound but want to automate the process to increase my work efficiency.

Zev Averbach

Rahil, say your keywords are in the "A" column of rahils_keywords.xlsx file, in the worksheet called keywords. At the shell, install this dependency:

> pip install openpyxl

Then in your text editor or Python REPL:

import webbrowser

from openpyxl import load_workbook


def google_search_keywords_from_spreadsheet(path: str, sheet: str, column: str):
    wb = load_workbook(filename=path)
    worksheet = wb[sheet]
    num_rows = worksheet.max_row

    for row_num in range(num_rows):
        cell = f"{column}{row_num + 1}"
        keyword = worksheet[cell].value
        if keyword: # skip blank cells
            url = f"https://google.com/search?q={keyword}"
            print(f'searching for keyword "{keyword}"...')
            webbrowser.open(url)

google_search_keywords_from_spreadsheet(
    path="rahils_keywords.xlsx",
    sheet="keywords",
    column="A",
)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Script to open multiple Chrome tabs each for a Google search from a list of keywords present in an Excel sheet

List Excel Sheet & Chart Tabs

Chrome Extension - Open Multiple Tabs

Open multiple URLs in the Chrome browser

Is it possible to open multiple tabs but not load the URLs?

How to copy URLs of all open Chrome tabs without an extension

How to make Chrome open bookmarks and URLs in new tabs?

Ways to see a list of all the tabs open in Chrome?

Timestamp script for multiple columns (Specific ones) for multiple tabs in one sheet

Open multiple tabs and execute command in shell script

How to open a list of urls on new tabs in Selenium + Python?

Is there way to query multiple urls using chrome.tabs

Multiple tabs issue during the downloading of the Excel sheet from Jasper server

Get list of values from multiple tabs and copy to a column in another sheet?

Save open tabs in Chrome

Is it possible to open multiple instances or split view of chrome developer tools tabs?

How to get a list of open tabs from chrome? | C#

Save list of open tabs in Google Chrome when not responding?

Open URLs in Chrome Notifications

Script to open a specific Excel file/sheet depending on time/date

How to write a script that will open up multiple tabs in the terminal?

Is there a way to copy URLs from all open tabs in a Google Chrome (or other browser) window into an email?

Multiple open tabs in Firefox

How to loop through multiple url and open urls in new tabs using selenium python chromedriver

VBA script to consolidate multiple excel sheets into one sheet

Get URLs of all open tabs using Python

Is there a method to export the URLs of the open tabs of a Firefox window?

How to save open tabs's URLs to a file?

Location of the URLs of the open tabs of Chromium browser in Ubuntu