# coding: utf-8
import time

from lxml import etree


def switch_domain(country):
    domain = "https://vendorcentral.amazon.com/"

    if country == "jp":
        domain = "https://vendorcentral.amazon.co.jp/"
    if country == "uk":
        domain = "https://vendorcentral.amazon.co.uk/"
    if country == "fr":
        domain = "https://vendorcentral.amazon.fr/"
    if country == "ca":
        domain = "https://vendorcentral.amazon.ca/"
    if country == "mx":
        domain = "https://vendorcentral.amazon.com.mx/"

    return domain


def domain_page(page,country):
    url = switch_domain(country)
    page.get(url)
    while True:
        time.sleep(1)
        title = page.title
        if title == "Amazon Sign-In":
            print("请登录账号")
            continue

        tree = etree.HTML(page.html)
        element = tree.xpath('//*[@id="cvf-submit-otp-button-announce"]')
        if element:
            print('请输入验证码')
        else:
            break