هر وقت دوست داشت کار می کنه !!!

سوال

سلام دوستان

من دارم یک ربات اینستاگرام می سازم اما نمی دونم چرا هروقت دلش می خواهد کار می کند و هروقت دوست ندارد کار نمی کند

به عبارتی امروز کار می کند  ، بهد از پنج دقیقه عینا همان کد بدون تغیر کار نمی کند!!!

چرا؟

 

این هم کد من :

from selenium import webdriver

from time import sleep
from random import sample
from selenium.common.exceptions import NoSuchElementException
user=”my user name”
password =”my password”
class UnFollow():
def __init__(self) :
self.login(user,password)

#—————————————————-
def login(self,user,password):

#self.driver = webdriver.Chrome(executable_path=r”C:UsersyasfaDesktopNew folderchromedriver.exe”)

self.driver = webdriver.Firefox(executable_path=r”C:UsersyasfaDesktopNew foldergeckodriver.exe”)

self.driver.get(‘https://instagram.com/accounts/login’)

sleep(2)

user_name_instag =self.driver.find_element_by_xpath(
‘/html/body/div[1]/section/main/div/div/div[1]/div[2]/form/div/div[1]/div/label/input’)

user_name_instag.send_keys(user)

sleep(2)

password_instag =self.driver.find_element_by_xpath(
“/html/body/div[1]/section/main/div/div/div[1]/div[2]/form/div/div[2]/div/label/input”)

password_instag.send_keys(password)

sleep(3)

self.driver.find_element_by_xpath(
‘/html/body/div[1]/section/main/div/div/div[1]/div[2]/form/div/div[3]’).click()

sleep(4)

self.driver.get(‘https://www.instagram.com/khamenei_ir/’)
sleep(3)

self.driver.find_element_by_xpath(
‘/html/body/div[1]/section/main/div/header/section/ul/li[2]/a/div’).click()
sleep(1)

#s= self.driver.find_element_by_tag_name(‘span’).text  *working*

#———————————————————————————–

number1 = 1
number2 = 1
number3 = 1
list_khamenee_memmber = []
list_meysame_motee_memmber = []
list_haj_agha_ahadee_memmber = []
zarfeat = 10

#———————————————————————————–
while number1<=zarfeat:

try:
s= self.driver.find_element_by_xpath(
‘/html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number1) +’]/div/div[2]/div[1]/div/div/span/a/span’).text
#the up xpath is diffrent the down xpath so i want to use try except else

list_khamenee_memmber.append(s)

except NoSuchElementException:

s= self.driver.find_element_by_xpath(
‘ /html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number1) +’]/div/div[2]/div/div/div/span/a/span’).text

list_khamenee_memmber.append(s)

number1 += 1
print(3*’/n’,”================================================================”,3*’/n’)
#———————————————————————————–

sleep(3)

self.driver.get(‘https://www.instagram.com/meysammotieee/’)
sleep(3)

self.driver.find_element_by_xpath(
‘/html/body/div[1]/section/main/div/header/section/ul/li[2]/a/div’).click()
sleep(1)

while number2<=zarfeat:

try:
s= self.driver.find_element_by_xpath(
‘/html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number2) +’]/div/div[2]/div[1]/div/div/span/a/span’).text
#the up xpath is diffrent the down xpath so i want to use try except else

list_meysame_motee_memmber.append(s)

except NoSuchElementException:

s= self.driver.find_element_by_xpath(
‘ /html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number2) +’]/div/div[2]/div/div/div/span/a/span’).text

list_meysame_motee_memmber .append(s)

number2 += 1
#———————————————————————————–

sleep(3)

self.driver.get(‘https://www.instagram.com/ahadi.ir/’)
sleep(3)

self.driver.find_element_by_xpath(
‘/html/body/div[1]/section/main/div/header/section/ul/li[2]/a/div’).click()
sleep(1)

while number3<=zarfeat:

try:
s= self.driver.find_element_by_xpath(
‘/html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number3) +’]/div/div[2]/div[1]/div/div/span/a/span’).text
#the up xpath is diffrent the down xpath so i want to use try except else

list_haj_agha_ahadee_memmber .append(s)

except NoSuchElementException:

s= self.driver.find_element_by_xpath(
‘ /html/body/div[5]/div/div/div/div[2]/ul/div/li[‘+ str(number3) +’]/div/div[2]/div/div/div/span/a/span’).text

list_haj_agha_ahadee_memmber.append(s)

number3 += 1
print(3*’n’,list_khamenee_memmber,3*’n’ ,
list_meysame_motee_memmber,3*’n’,
list_haj_agha_ahadee_memmber,3*’n’)

set_one = set( list_khamenee_memmber )

set_two = set( list_meysame_motee_memmber )

set_three = set( list_haj_agha_ahadee_memmber )

A = set_one.intersection(set_two)
B = set_one.intersection(set_three)

c =  A.intersection(B)

if c==set():
print(“no memmber found”,3*’n’)

def main():
my_un_follow_bot = UnFollow()
# the main part of code is this:
if __name__ == ‘__main__’:
main()

0
holo 6 ماه 0 پاسخ ها 75 دیده شده 0

ارسال یک پاسخ