Automatic operation of Chrome with Python + Selenium + pandas

Automatic operation of Chrome with Python + Selenium + pandas

Overview

As the title says

The sample reads two columns of Excel in sequence. Just do a Google search with two keywords

However, technically, if you prepare this much, the rest will be applied Automatic input from a huge amount of Excel for web-based slip system I think it is possible to do what is called RPA.

Usage environment

Python 3.8.1 Visual Studio Code 1.41.1 openpyxl 3.0.3 pandas 1.0.3 selenium 3.141.0

Prepared Excel image

image.png

Source code

sele.py



#Python + Selenium +Automatic operation of Chrome with pandas
import time
from selenium import webdriver
import chromedriver_binary
import pandas as pd


#Open Excel with search words in pandas
search_value_table = pd.read_excel(".\\search_word.xlsx", dtype=str)

#Open Chrome and open Google with selenium. And a little weight
driver = webdriver.Chrome()
driver.get('https://www.google.com/')
time.sleep(2)

#Repeated search
for index, row in search_value_table.iterrows():
    #Connect two search terms with a space
    search_word = row['Search name 1'] + " " + row['Search name 2']

    #Find Google search box find_element_by_name
    search_box = driver.find_element_by_name("q")

    search_box.send_keys(search_word)
    search_box.submit()
    time.sleep(2)

    #Click the Google logo to go back
    driver.find_element_by_id("logo").click();

driver.quit()



Recommended Posts

Automatic operation of Chrome with Python + Selenium + pandas
[Python] Operation memo of pandas DataFrame
[Python] Operation of enumerate
Try running Google Chrome with Python and Selenium
Basic operation of pandas
Basic operation of Pandas
Automatic version sync of chrome driver binary with chrome
ScreenShot with Selenium (Python)
Scraping with Selenium [Python]
Automatic posting of web design gary site with python + selenium (1) Environment construction
Basic operation of Python Pandas Series and Dataframe (1)
Automatic follow on Twitter with python and selenium! (RPA)
Automate Chrome with Python and Selenium on your Chromebook
Get the operation status of JR West with Python
How to switch to smartphone mode with Python + Selenium + Chrome
Read csv with python pandas
Scraping with selenium in Python
Automatic update of Python module
S3 operation with python boto3
Python: Working with Firefox with selenium
Scraping with Selenium in Python
[Python] Change dtype with pandas
Memories of fighting with Selenium
Scraping with Selenium + Python Part 2
The Power of Pandas: Python
Get information equivalent to the Network tab of Chrome developer tools with Python + Selenium
Notes on handling large amounts of data with python + pandas
Get a list of purchased DMM eBooks with Python + Selenium
Try to automate the operation of network devices with Python
Scraping with Selenium in Python (Basic)
Scraping with Python, Selenium and Chromedriver
Getting Started with Python Basics of Python
[Python] Join two tables with pandas
Life game with Python! (Conway's Game of Life)
10 functions of "language with battery" python
1. Statistics learned with Python 1-1. Basic statistics (Pandas)
Implementation of Dijkstra's algorithm with python
[Automation with python! ] Part 2: File operation
Coexistence of Python2 and 3 with CircleCI (1.0)
Excel aggregation with Python pandas Part 1
[Python] Format when to_csv with pandas
Basic study of OpenCV with Python
[Let's play with Python] Aiming for automatic sentence generation ~ Completion of automatic sentence generation ~
I wrote the basic operation of Pandas with Jupyter Lab (Part 1)
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
I wrote the basic operation of Pandas with Jupyter Lab (Part 2)
Get the width of the div on the server side with Selenium + PhantomJS + Python
Basics of binarized image processing with Python
[Examples of improving Python] Learning Python with Codecademy
[Python] Summary of how to use pandas
Get html from element with Python selenium
Automatic collection of stock prices using python
WebUI test with Python2.6 + Selenium 2.44.0 --profile setting
Python + Selenium Frequently used operation method summary
Import of japandas with pandas 1.0 and above
Execute Python script with cron of TS-220
Automatic update method with python Pyinstaller exe
Check the existence of the file with python
Algorithm learned with Python 8th: Evaluation of algorithm
Operation of virtual currency automatic trading script
I tried using Selenium with Headless chrome