Compare commits
No commits in common. "19ccd06623a670225c728a91b00f41ee636677f3" and "68903176b1597743470abd55798062e7710b54f2" have entirely different histories.
19ccd06623
...
68903176b1
|
@ -1,2 +1 @@
|
||||||
.env
|
.env
|
||||||
__pycache__
|
|
|
@ -7,8 +7,6 @@ from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.common.keys import Keys
|
from selenium.webdriver.common.keys import Keys
|
||||||
import time,os
|
import time,os
|
||||||
|
|
||||||
import r_kuji
|
|
||||||
|
|
||||||
# 変数初期化 ********************************************************************
|
# 変数初期化 ********************************************************************
|
||||||
profile_dir = "/tmp/profile"
|
profile_dir = "/tmp/profile"
|
||||||
username = os.environ["RAKUTENID"]
|
username = os.environ["RAKUTENID"]
|
||||||
|
@ -124,8 +122,4 @@ def main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
time.sleep(60) # selniumコンテナの起動を待つ待機
|
time.sleep(60) # selniumコンテナの起動を待つ待機
|
||||||
main()
|
main()
|
||||||
try:
|
|
||||||
r_kuji.rkuji()
|
|
||||||
except:
|
|
||||||
print("rkuji 失敗")
|
|
|
@ -1,61 +0,0 @@
|
||||||
|
|
||||||
from selenium import webdriver
|
|
||||||
from selenium.webdriver.common.by import By
|
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
|
||||||
from selenium.webdriver.common.keys import Keys
|
|
||||||
import time,os
|
|
||||||
|
|
||||||
rkuji_list_url = "https://rakucoin.appspot.com/rakuten/kuji/"
|
|
||||||
rkuji_list_xpath = "//table/tbody/tr/td/a"
|
|
||||||
|
|
||||||
class class_rkuji:
|
|
||||||
def __init__(self, profile_dir="/tmp/profile"):
|
|
||||||
options = webdriver.ChromeOptions()
|
|
||||||
options.add_argument("--window-size=1920,1080")
|
|
||||||
options.add_argument("--user-data-dir=" + profile_dir )
|
|
||||||
self.driver = webdriver.Remote(
|
|
||||||
command_executor="http://selenium:4444/wd/hub",
|
|
||||||
options=options
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_rkuji_urls(self, url, xpath):
|
|
||||||
self.driver.get(url)
|
|
||||||
self.urls = self.driver.find_elements(By.XPATH, xpath)
|
|
||||||
self.url_txts = [url.get_attribute("href") for url in self.urls ]
|
|
||||||
|
|
||||||
def challenge_rkuji(self):
|
|
||||||
for u in self.url_txts:
|
|
||||||
if 'redirect' in u:
|
|
||||||
print(f'ラッキーくじ:「{u}」はスキップ。(理由:redirect)')
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
self.driver.get(u)
|
|
||||||
kuji_title = self.driver.title
|
|
||||||
except:
|
|
||||||
print(f'ラッキーくじ:「{u}」はスキップ。(理由:アクセス失敗)')
|
|
||||||
continue
|
|
||||||
|
|
||||||
if(len(self.driver.find_elements(By.ID, "entry"))>0):
|
|
||||||
print(f'ラッキーくじ:くじを引きます。({kuji_title})')
|
|
||||||
time.sleep(5)
|
|
||||||
try:
|
|
||||||
start_button = self.driver.find_element(By.ID, "entry")
|
|
||||||
start_button.click()
|
|
||||||
WebDriverWait(self.driver,60).until(EC.url_changes(u))
|
|
||||||
print(f'ラッキーくじ:くじを引きました。({kuji_title})')
|
|
||||||
self.driver.save_screenshot('./ss/r_kuji.png')
|
|
||||||
time.sleep(5)
|
|
||||||
except:
|
|
||||||
(f'ラッキーくじ:「{kuji_title}」はスキップ。(理由:くじ引き失敗)')
|
|
||||||
else:
|
|
||||||
print(f'ラッキーくじ:「{kuji_title}」はスキップ。(理由:くじ引き不能)')
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
self.driver.quit()
|
|
||||||
|
|
||||||
def rkuji():
|
|
||||||
driver = class_rkuji()
|
|
||||||
driver.get_rkuji_urls(rkuji_list_url, rkuji_list_xpath)
|
|
||||||
driver.challenge_rkuji()
|
|
||||||
driver.close()
|
|
|
@ -6,8 +6,6 @@ services:
|
||||||
container_name: 'selenium'
|
container_name: 'selenium'
|
||||||
volumes:
|
volumes:
|
||||||
- /dev/shm:/dev/shm
|
- /dev/shm:/dev/shm
|
||||||
logging:
|
|
||||||
driver: none
|
|
||||||
python3:
|
python3:
|
||||||
build: ./python3
|
build: ./python3
|
||||||
container_name: 'rpoint-getter'
|
container_name: 'rpoint-getter'
|
||||||
|
|
Loading…
Reference in New Issue