Skip to content

Instantly share code, notes, and snippets.

@umihico
Last active January 17, 2019 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umihico/eb738c7335bc5a254c2bea3831aa0011 to your computer and use it in GitHub Desktop.
Save umihico/eb738c7335bc5a254c2bea3831aa0011 to your computer and use it in GitHub Desktop.
ヤフーオークション再出品スクリプト selenium & python

ヤフーオークション再出品スクリプト selenium & python

import os
from selenium.webdriver import Chrome, ChromeOptions
Chrome.xpath = Chrome.find_element_by_xpath
Chrome.xpaths = Chrome.find_elements_by_xpath
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
def logined(self):
return bool(self.xpaths("//div[@class='yjmthloginarea']/a[text()='ログアウト']"))
Chrome.logined = logined
def republish():
userdata_dir = 'UserData'
os.makedirs(userdata_dir, exist_ok=True)
chromeoptions = ChromeOptions()
chromeoptions.add_argument('--user-data-dir=' + userdata_dir)
chrome = Chrome(chrome_options=chromeoptions)
url = "https://auctions.yahoo.co.jp/closeduser/jp/show/mystatus?select=closed&hasWinner=0"
chrome.get(url)
while True:
if chrome.logined():
break
sleep(1)
while True:
chrome.refresh()
resell_buttons = chrome.find_elements_by_xpath(
"//a[./img[@alt='再出品']]")
if not resell_buttons:
break
resell_buttons[0].click()
try:
chrome.find_element_by_xpath("//td[@class='decFormTab01Off']/p/a").click()
except Exception as e:
pass
wait = WebDriverWait(chrome, 20)
wait.until(expected_conditions.visibility_of_element_located(
(By.XPATH, "//input[@value='確認画面へ' or @value='確認する']"))).click()
chrome.find_element_by_xpath(
"//input[@id='auc_preview_submit_up' or @value='ガイドラインに同意して出品する']").click()
chrome.get(url)
if __name__ == '__main__':
republish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment