kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
545 stars 66 forks source link

detected on bet356 #6

Closed xtwxfxk closed 1 year ago

xtwxfxk commented 1 year ago
import os
from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
from selenium_driverless.types.by import By

options = ChromeOptions()
profile = profiles.Windows()

driver = Chrome(profile, options=options, driverless_options=True)

driver.get('https://www.365365824.com/#/IP/B16')
### login ...
eles = driver.find_elements(by=By.XPATH, value='//div[contains(@class, "ovm-ParticipantOddsOnly")]')

eles[0].click() ### auto logout`

./scripts/options.py can add default "user_data_dir" parameter to define custome profile dir?

kaliiiiiiiiii commented 1 year ago
from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
import time

profile = profiles.Windows() # or .Android
options = ChromeOptions()
driver = Chrome(profile=profile, options=options, driverless_options=True)

back = driver.current_window_handle
# get url
driver.get('https://365365824.com/#/IP/B16')
driver.switch_to.target(driver.targets[0]["targetId"])

time.sleep(5)
driver.switch_to.target(back)

driver.quit()  # Execute on the End!

works for me @xtwxfxk please close this issue in case it gets resolved by that

xtwxfxk commented 1 year ago

@kaliiiiiiiiii can view data Unable to operate like click to place a bet

eles = driver.find_elements(by=By.XPATH, value='//div[contains(@class, "ovm-ParticipantOddsOnly")]')
eles[0].click() ### detected and auto logout
kaliiiiiiiiii commented 1 year ago

@kaliiiiiiiiii can view data Unable to operate like click to place a bet

eles = driver.find_elements(by=By.XPATH, value='//div[contains(@class, "ovm-ParticipantOddsOnly")]')
eles[0].click() ### detected and auto logout

Yeah expected that. Ocurs because .click() basically executes elem.click() with javascript

awaiting implementation at https://github.com/kaliiiiiiiiii/Selenium-Driverless/issues/5

xtwxfxk commented 1 year ago

ok thank you

kaliiiiiiiiii commented 1 year ago

@xtwxfxk following script worked for me as a workaround for now:

from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
from selenium_driverless.types.by import By
import time

profile = profiles.Windows() # or .Android
options = ChromeOptions()
driver = Chrome(profile=profile, options=options, driverless_options=True)

back = driver.current_window_handle
# get url
driver.get('https://365365824.com/#/IP/B16')
driver.switch_to.target(driver.targets[0]["targetId"])

time.sleep(5)
driver.switch_to.target(back)

eles = driver.find_elements(by=By.XPATH, value='//div[contains(@class, "ovm-ParticipantOddsOnly")]')
elem = eles[0]

script = """
// https://stackoverflow.com/a/38073679/20443541
function fireClick(node){
    if (document.createEvent) {
        var evt = document.createEvent('MouseEvents');
        evt.initEvent('click', true, false);
        node.dispatchEvent(evt);    
    } else if (document.createEventObject) {
        node.fireEvent('onclick') ; 
    } else if (typeof node.onclick == 'function') {
        node.onclick(); 
    }
};
fireClick(arguments[0])
"""
driver.execute_script(script,elem)

Insights: looks like bet365 detected bare elem.click() calls.

also, they patch the elem.click.toString function with

(){var f=c.lastIndexOf(this);if(f>=0){return d[f]}return b(this)}
xtwxfxk commented 1 year ago

@xtwxfxk following script worked for me as a workaround for now:

from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
from selenium_driverless.types.by import By
import time

profile = profiles.Windows() # or .Android
options = ChromeOptions()
driver = Chrome(profile=profile, options=options, driverless_options=True)

back = driver.current_window_handle
# get url
driver.get('https://365365824.com/#/IP/B16')
driver.switch_to.target(driver.targets[0]["targetId"])

time.sleep(5)
driver.switch_to.target(back)

eles = driver.find_elements(by=By.XPATH, value='//div[contains(@class, "ovm-ParticipantOddsOnly")]')
elem = eles[0]

script = """
// https://stackoverflow.com/a/38073679/20443541
function fireClick(node){
    if (document.createEvent) {
        var evt = document.createEvent('MouseEvents');
        evt.initEvent('click', true, false);
        node.dispatchEvent(evt);    
    } else if (document.createEventObject) {
        node.fireEvent('onclick') ; 
    } else if (typeof node.onclick == 'function') {
        node.onclick(); 
    }
};
fireClick(arguments[0])
"""
driver.execute_script(script,elem)

Insights: looks like bet365 detected bare elem.click() calls.

also, they patch the elem.click.toString function with

(){var f=c.lastIndexOf(this);if(f>=0){return d[f]}return b(this)}

not use for me, still get error and auto logout

kaliiiiiiiiii commented 1 year ago

@xtwxfxk

  1. what do you mean by "auto logout" ? Can you provide a screenshot?
  2. are you trying to fill in the credentials and log-in? If yes, can you provide a example script? (please censor your credentials)
xtwxfxk commented 1 year ago

@kaliiiiiiiiii i use ipython now not write script

manual operation image

ipython control image

xtwxfxk commented 1 year ago

Perhaps using ActionChains can succeed

xtwxfxk commented 1 year ago

do you use telegram?

kaliiiiiiiiii commented 1 year ago

Perhaps using ActionChains can succeed

uh yeah possibly, but the question is still how to implement it.

I could use:

kaliiiiiiiiii commented 1 year ago

do you use telegram?

@xtwxfxk nah, but Discord (steve_abcdef username)

kaliiiiiiiiii commented 1 year ago

@xtwxfxk dumped some stuff at https://github.com/kaliiiiiiiiii/Selenium-Profiles/tree/dev/dev_stuff/bet365.com_analysis

feel free to tell if you see anything interesting//relevant about that stuff and detection

xtwxfxk commented 1 year ago

@xtwxfxk dumped some stuff at https://github.com/kaliiiiiiiiii/Selenium-Profiles/tree/dev/dev_stuff/bet365.com_analysis

feel free to tell if you see anything interesting//relevant about that stuff and detection

thanks

kaliiiiiiiiii commented 1 year ago

UPDATE: @xtwxfxk now bypassed without switch_to workarounds see https://github.com/kaliiiiiiiiii/Selenium-Driverless/discussions/18