def likes_persons_posts(num_images_to_like): count_posts = 0 sleep() while count_posts < num_images_to_like: # if statement looks for a video try: like_unlike_check() sleep() # right click on images to scroll right_arrow() sleep() count_posts += 1 except NoSuchElementException: print('Image is not a picture!') count_posts += 1
def like_people(number_of_people, number_pics_to_like): count = 0 followed = 0 while count < number_of_people: #clicks person's name to go their profile try: driver.find_element_by_class_name('FPmhX').click() sleep() except: right_arrow() count += 1 continue print('liking:' + driver.find_element_by_class_name('AC5d8').text) try: # If out of range. Go back and select next picture if stats_range() is False: driver.back() sleep() right_arrow() sleep() continue except: # if you can't find the stats still go back... driver.back() sleep() right_arrow() sleep() continue click_specific_post(0) sleep() likes_persons_posts(number_pics_to_like) sleep() #Goes back twice to get back to hashtag driver.back() sleep() driver.back() sleep() # right click on images to scroll right_arrow() count += 1 sleep()
for picture in range(posts - 1): #likes try: like_amount = driver.find_element_by_xpath( '''/html/body/div[3]/div/div[2]/div/article/div[2]/section[2]/div/a/span''' ).text likes += remove_k_m_periods_commas(like_amount) #likes += like_amount except: video_amount = driver.find_element_by_xpath( '''/html/body/div[3]/div/div[2]/div/article/div[2]/section[2]/div/span/span''' ).text video_views += remove_k_m_periods_commas(video_amount) # Right arrow right_arrow() time.sleep(randint(3, 4)) #print(picture, likes) # ################################-----BELOW----SEND DATA TO GOOGLE SHEETS-----##################################### # # use creds to create a client to interact with the Google Drive API scope = ['https://spreadsheets.google.com/feeds'] creds = ServiceAccountCredentials.from_json_keyfile_name( '../../../API Keys/GSheet_client_secret', scope) client = gspread.authorize(creds) # Find a workbook by name and open the first sheet # Make sure you use the right name here. follower_data_sheet = client.open(