Summary of scraping relations (selenium, pyautogui)

・ 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

Summary of scraping relations (selenium, pyautogui)
Scraping with selenium
Scraping with selenium ~ 2 ~
Scraping with Selenium
Selenium webdriver Summary of frequently used operation methods
Numerical summary of data
Successful scraping with Selenium
Summary about Python scraping
Summary of Tensorflow / Keras
Basics of Python scraping basics
Summary of pyenv usage
Summary of string operations
Summary of Python arguments
Scraping with Selenium [Python]
Python web scraping selenium
Summary of logrotate software logrotate
Summary of test method
Scraping the result of "Schedule-kun"
Scraping with selenium in Python
Scraping with Selenium + Python Part 1
Summary of Python3 list operations
2017.3.6 ~ 3.12 Summary of what we did
Scraping with Selenium in Python
Convenient usage summary of Flask
Summary of Linux distribution types
Web scraping using Selenium (Python)
Memories of fighting with Selenium
Basic usage of Pandas Summary
Scraping with Selenium + Python Part 2
[Python + Selenium] Tips for scraping
A brief summary of Linux
Summary of Proxy connection settings
I-town page scraping with selenium
Python Crawling & Scraping Chapter 4 Summary