Beispiel #1
0
def bot(data,items):

    firefox_profile = webdriver.FirefoxProfile()
    # firefox_profile.set_preference('permissions.default.image', 2)
    JsBuy = open('buy.js').read()
    JScode = open('additem.js').read()
    options = Options()
    options.add_argument('test-type')
    options.accept_untrusted_certs = True
    options.assume_untrusted_cert_issuer = True
    options.add_argument("user-data-dir=selenium")
    # options.set_headless(headless=True)

    driver = webdriver.Chrome(options=options)
    driver.set_window_size(1050, 650)
    url = "https://www.supremenewyork.com/shop/all/new"
    driver.get(url)
    time.sleep(1)
    wait()

    #
    # f = urllib.request.urlopen(url)
    print("Бот запущен", time.clock())


    items = findItems(items)

    for i in range(len(items)):
        cd = JScode.format(items[i].shopid, items[i].colid, items[i].itemid)
        driver.execute_script(cd)
        print("Товар добавлен в корзину", items[i], time.clock())

    JsBuy=JsBuy.format(name=data['fio'],email=data['email'],tel=data['tel']
                       ,adress=data['adress'],sity=data['sity'],cardnom=data['card_nom']
                       ,zip=data['postcode'],cvv=data['card_cvc'],card_type=data['card_type'],
                       card_month=data['card_month'],card_year=data['card_year'])
    driver.execute_script(JsBuy)
    print("Куплено", time.clock())
    time.sleep(60)
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.common.keys import Keys
import sys

# macos_firefox.py
# /Applications/Firefox.app/Contents/MacOS/firefox  --private-window https://www.uol.com.br

# Options
firefox_options = Options()
firefox_options.log.level = 'debug'
firefox_options.add_argument('-private')
firefox_options.accept_untrusted_certs = True
firefox_options.assume_untrusted_cert_issuer = True
firefox_options.binary_location = '/Applications/Firefox.app/Contents/MacOS/firefox'
# firefox_options.headless = True

# FirefoxProfile
firefox_profile = FirefoxProfile();
firefox_profile.set_preference('browser.privatebrowsing.autostart', True)
firefox_profile.set_preference('pdfjs.disabled', True)
firefox_profile.set_preference('browser.download.folderList', 2)
firefox_profile.set_preference('browser.download.panel.shown', False)
firefox_profile.set_preference('browser.tabs.warnOnClose', False)
firefox_profile.set_preference('browser.tabs.animate', False)
firefox_profile.set_preference('browser.fullscreen.animateUp', 0)
firefox_profile.set_preference('geo.enabled', False)
firefox_profile.set_preference('browser.urlbar.suggest.searches', False)
firefox_profile.set_preference('browser.tabs.warnOnCloseOtherTabs', False)
firefox_profile.update_preferences()
Beispiel #3
0
if __name__ == "__main__":
    hostlist = open('hostlist', 'r')
    hosts = hostlist.readlines()
    call(["mkdir", "output"])
    for host in hosts:
        call(["killall", "firefox"])
        bmcfw = ''
        sdr = ''
        mefw = ''
        address = host.split(';')[0]
        login = host.split(';')[1][:-1]
        call(["mkdir", "output/" + address])
        print 'Processing ' + address
        options = Options()
        options.headless = True
        options.accept_untrusted_certs = True
        driver = Firefox(executable_path='geckodriver', options=options)
        wait = WebDriverWait(driver, timeout=10)
        driver.get("http://" + address)
        check = driver.find_elements_by_xpath('//*[@id]')
        checklist = []
        for element in check:
            checklist.append(element.get_attribute('id'))
        if 'LOGIN_VALUE_1' in checklist:
            driver.get("http://" + address + "/page/login.html")
            driver.find_element_by_id("login_username").click()
            driver.find_element_by_id("login_username").clear()
            driver.find_element_by_id("login_username").send_keys(login)
            driver.find_element_by_id("login_password").clear()
            driver.find_element_by_id("login_password").send_keys("operator")
            driver.find_element_by_id("LOGIN_VALUE_1").click()