웹 로그인 자동화
본문
from django.shortcuts import render
from django.http import HttpResponse
from urllib.request import urlopen
import requests
import urllib.request
from bs4 import BeautifulSoup
from yarl import URL
from bs4 import BeautifulSoup as bs
import schedule
import sched, time
import pymysql
from datetime import datetime, timedelta
from threading import Thread
from time import sleep
from selenium import webdriver
import webbrowser
from selenium import webdriver
def index(request):
return HttpResponse("111")
def do_txt(a,b, x):
print('창열기')
driver = webdriver.Chrome('C:\dev\page_project\src\chromedriver.exe', chrome_options=options)
print('로그인창')
time.sleep(2)
continue_link.click()
time.sleep(5)
driver.quit()
driver 종료
s = sched.scheduler(time.time, time.sleep)
MySQL Connection 연결
conn = pymysql.connect(host='localhost', user='root', password='1111',db='keyword', charset='utf8')
curs = conn.cursor(pymysql.cursors.DictCursor)
def do_something(sc):
now_time = datetime.now().strftime('%H:%M:%S')
print ('Doing stuff...' + str(now_time))
do your stuff
sql = "select * from gword where num=%s"
curs.execute(sql, (1))
sql = "select * from gword"
curs.execute(sql,)
rows = curs.fetchall()
for row in rows:
print(row)
print('id:'+row['title1'] + ', pw:' + row['title2'])
do_txt(row['title1'], row['title2'], row['sok'] )
conn.commit()
s.enter(10, 1, do_something, (sc,))
s.enter(10, 1, do_something, (s,))
s.run()
conn.close()
while True:
Code executed here
print('test')
time.sleep(60)
#웹크롤러 #자동화작업 #pymysql #python