・ Do pip install pyautogui and selenium
selenium
#Import library
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import os
import time
import requests
from selenium.webdriver.common.keys import Keys
import requests
from bs4 import BeautifulSoup
import pyautogui
import pandas as pd
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
import datetime as dt
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
def LOG_IN():
#Specify chrome driver
driver = webdriver.Chrome(**chromedriver.exe**)
driver.get("hoghoge")
#Get user ID, password, login button tag
userId = driver.find_element_by_name('userId')
password = driver.find_element_by_name('password')
loginButton = driver.find_element_by_name('login')
#Enter your user ID and password to log in
userId.send_keys('hogehoge')
password.send_keys('hogehoge')
loginButton.submit()
return driver
・ Various specification methods
#Element specification
driver.find_element_by_name()
driver.find_element_by_xpath()
driver.find_element_by_id()
#Method of operation
.click()
.clear()
.send_keys()
.text
pyautogui
import os
import pandas as pd
import pyautogui
import pyperclip
from time import sleep
import win32com.client
import win32gui
import time
import openpyxl
from tkinter import *
import glob
#Find out where your mouse is now
print(pyautogui.position())
pyautogui.moveTo(35,170, duration=0.1)#Move
pyautogui.click()#click
pyautogui.dragTo(1350,670, duration=0.3, button='left')#drag
pyautogui.typewrite(txt)#Text input
#Clipboard copy
df = pd.read_clipboard()
#Get handler
hWnd = win32gui.FindWindow(0, "app name")
if hWnd is not 0:
win32gui.SetForegroundWindow(hWnd)
Recommended Posts