-
Notifications
You must be signed in to change notification settings - Fork 37
Update script.py #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Beatriz361
wants to merge
10
commits into
izmcm:master
Choose a base branch
from
Beatriz361:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update script.py #22
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
beb1d46
Update script.py
Beatriz361 d15a476
Revert "Update script.py"
Beatriz361 158365e
Revert "Revert "Update script.py""
Beatriz361 dab8802
Update script.py
Beatriz361 12fbd5b
Revert "Update script.py"
Beatriz361 5f1b0a7
Merge branch 'master' of https://github.com/Beatriz361/BBBot-1
Beatriz361 f3e936b
Revert "Update script.py"
Beatriz361 938b288
Update script.py
Beatriz361 aa7a7b2
Create script - Copia.py
Beatriz361 0beceb4
Update script.py
Beatriz361 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.action_chains import ActionChains | ||
| from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | ||
| import time | ||
| from binascii import a2b_base64 | ||
| import processing | ||
| from getpass import getpass | ||
|
|
||
| login = "" | ||
| password = "" | ||
|
|
||
| login = input("Abaixo precisaremos das suas credenciais do Globo.com.\nDigite seu email: ") | ||
| password = getpass() | ||
|
|
||
| loginUrl = "https://minhaconta.globo.com/" | ||
|
|
||
| #url = "https://gshow.globo.com/realities/bbb/bbb20/votacao/paredao-bbb20-quem-voce-quer-eliminar-babu-flayslane-ou-thelma-3ade29ed-5052-41ef-8414-226cca50933a.ghtml" | ||
| url = input("Copie e cole a URL do site da votação: ") | ||
|
|
||
| browser = None | ||
| try: | ||
| caps = DesiredCapabilities().CHROME.copy() | ||
| caps["pageLoadStrategy"] = "eager" # interactive | ||
| browser = webdriver.Chrome(capabilities=caps) | ||
| # browser = webdriver.Chrome() | ||
| except: | ||
| caps = DesiredCapabilities().FIREFOX.copy() | ||
| caps["pageLoadStrategy"] = "eager" # interactive | ||
| browser = webdriver.Firefox(capabilities=caps) | ||
| # browser = webdriver.Firefox() | ||
| browser.get(loginUrl) | ||
|
|
||
| time.sleep(10) | ||
| print("\nfazendo o login...") | ||
| browser.find_element_by_id('login').send_keys(login) | ||
| browser.find_element_by_id('password').send_keys(password) | ||
| browser.find_elements_by_css_selector('#login-form .button')[0].click() | ||
|
|
||
| print("login finalizado...") | ||
|
|
||
| time.sleep(5) | ||
| browser.get(url) | ||
|
|
||
| print("iniciando o bot") | ||
| while(1): | ||
| try: | ||
| # title = browser.find_elements_by_class_name('_1QJO-RxRXUUbq_pPU1oVZK')[0].text | ||
| # title = browser.find_element_by_xpath('//*[@id="roulette-root"]/div/div[1]/div[3]/div/div/div') | ||
| title = browser.find_element_by_xpath('/html/body/div[2]/div[4]/div/div[1]/div[3]/div/div/div').text | ||
|
|
||
| break | ||
| except: | ||
| pass | ||
|
|
||
| print(title) | ||
|
|
||
| time.sleep(5) | ||
|
|
||
| titleParts = title.split('?')[1] | ||
|
|
||
| print(titleParts) | ||
|
|
||
| ##### paredão triplo ##### | ||
| namesAux = titleParts.split(', ') | ||
| names = [namesAux[0].strip()] | ||
| names = names + namesAux[1].split(' ou ') | ||
|
|
||
| option = input("Quem você quer eliminar?\n1. "+names[0]+"\n2. "+names[1]+"\n3. "+names[2]+"\nDigite o número correspondente: ") | ||
| while not option in ["1", "2", "3"]: | ||
| option = input("Quem você quer eliminar?\n1. "+names[0]+"\n2. "+names[1]+"\n3. "+names[2]+"\nDigite o número correspondente: ") | ||
|
|
||
| ##### paredão duplo ##### | ||
| #namesAux = titleParts.split(' ou ') | ||
| #names = [namesAux[0].strip(), namesAux[1]] | ||
|
|
||
| flayslane = names[int(option)-1] | ||
| idxName = names.index(flayslane) | ||
| totalVotes = 0 | ||
|
|
||
| # for _ in range(100): | ||
| while True: | ||
| # print(nameSearch + " é o botao " + str(idxName)) | ||
|
|
||
| element = [] | ||
| while(1): | ||
| try: | ||
| #print("procurando nome") | ||
| # element = browser.find_elements_by_class_name('_1Y7EGDbQkmzYnNZcD4tztg') | ||
| element = [ | ||
| browser.find_element_by_xpath('/html/body/div[2]/div[4]/div/div[1]/div[4]/div[1]'), | ||
| browser.find_element_by_xpath('/html/body/div[2]/div[4]/div/div[1]/div[4]/div[2]'), | ||
| browser.find_element_by_xpath('/html/body/div[2]/div[4]/div/div[1]/div[4]/div[3]'), | ||
| ] | ||
| break | ||
| except: | ||
| pass | ||
|
|
||
| # print(idxName) | ||
| # print(element) | ||
| elementBtn = element[idxName] | ||
|
|
||
| # scroll down | ||
| browser.execute_script("window.scrollTo(0, 700)") | ||
|
|
||
| ac2 = ActionChains(browser) | ||
| ac2.move_to_element(elementBtn).click().perform() | ||
| time.sleep(3) | ||
|
|
||
| outSideLoop = True | ||
| innerLoop = True | ||
| while outSideLoop: | ||
| ac = ActionChains(browser) | ||
| captchaBox = [] | ||
|
|
||
| vote_succeeded = False | ||
|
|
||
| while innerLoop: | ||
| try: | ||
| # print("procurando o captcha") | ||
| captchaBox = browser.find_elements_by_class_name('gc__2Qtwp') | ||
| if captchaBox != []: | ||
| if len(captchaBox[0].text) > 2: | ||
| break | ||
|
|
||
| # vote_confirmation = browser.find_elements_by_class_name('_2uL8BLYO2wcSLbb32p6m8D') | ||
| time.sleep(1) | ||
|
|
||
| value = browser.find_element_by_xpath('/html/body/div[2]/div[4]/div/div[3]/div/div/div[1]/div[2]/button') | ||
| if value.text != '': | ||
| vote_succeeded = True | ||
| outSideLoop = False | ||
| innerLoop = False | ||
| break | ||
| except: | ||
| pass | ||
|
|
||
| if vote_succeeded: | ||
| totalVotes += 1 | ||
| print(totalVotes, 'votos com sucesso') | ||
| break | ||
|
|
||
| imageSearchName = captchaBox[0].text.split('\n')[-1] | ||
| print("procurando por " + imageSearchName) | ||
|
|
||
| captcha = [] | ||
| while(1): | ||
| try: | ||
| captcha = browser.find_elements_by_class_name('gc__3_EfD')[0] | ||
| break | ||
| except: | ||
| pass | ||
|
|
||
| captchaSrc = captcha.get_attribute("src") | ||
|
|
||
| data = captchaSrc.split(';base64,')[1] | ||
| binary_data = a2b_base64(data) | ||
|
|
||
| filename = imageSearchName + '.png' | ||
|
|
||
| fd = open('BBB20/captchas/' + filename, 'wb') | ||
| fd.write(binary_data) | ||
| fd.close() | ||
|
|
||
| processing.processImage(filename) | ||
| points = processing.findInCaptcha(filename) | ||
|
|
||
| if points != []: | ||
| # print("a imagem se encontra nos pontos: " + str(points[0]) + " X " + str(points[1])) | ||
| # print("o tamanho do captcha é " + str(captcha.size['width']) + " X " + str(captcha.size['height'])) | ||
|
|
||
| posX = points[0] - captcha.size['width']/2 | ||
| posY = points[1] - captcha.size['height']/2 | ||
|
|
||
| ac.move_to_element(captcha).move_by_offset(posX, posY).click().perform() | ||
| time.sleep(3) | ||
| else: | ||
| print("erro - captcha não encontrado") | ||
|
|
||
| time.sleep(1) | ||
|
|
||
| browser.refresh() | ||
| time.sleep(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.