hey everyone, i'm trying to improve my instagram selenium bot with pandas.
i want him to add every url that he is visiting to a file and work only if the current url is in the file,
so he wont like and comment to posts on instagram that he allready liked.
another problem is that the file is erasing and re-write every time the program runs.
a part of the code is below, if you know how can i do it or you have improving suggestion i would love to hear.
i want him to add every url that he is visiting to a file and work only if the current url is in the file,
so he wont like and comment to posts on instagram that he allready liked.
another problem is that the file is erasing and re-write every time the program runs.
a part of the code is below, if you know how can i do it or you have improving suggestion i would love to hear.
def execute(self): before_moving_to_file = [] df = pd.read_csv("instagram_liked_links.csv") for link in self.links: self.browser.get(link) currentUrl = self.browser.current_url before_moving_to_file.append(currentUrl) updated_user_df = pd.DataFrame(before_moving_to_file) updated_user_df.to_csv('instagram_liked_links.csv'.format(strftime("%Y%m%d-%H%M%S")), encoding='utf-8', index=False) time.sleep(1) try: if currentUrl in df: continue else: self.browser.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(1) self.comment() time.sleep(2) self.like() self.price += 0.02 sleeptime = random.randint(18, 28) time.sleep(sleeptime) except Exception: continue