Trying the scraper with selenium on Instagram. Learning about xpaths and cool little tricks - whether to grab class, name or id, and yadda yadda. See code snippet here, where I use xpaths and some syntax to make sure I only capture the buttons of the accounts I haven't followed already :
def click_to_follow(browser):
my_follow_btn_xpath = "//button[contains(text(), 'Follow')][not(contains(text(), 'Following'))]" # grabbing button elements containing 'follow'
follow_btn_elments = browser.find_elements_by_xpath(my_follow_btn_xpath)
for btn in follow_btn_elments:
time.sleep(2) # self-throttle
try:
btn.click()
except:
pass
(first code snippet I post to a blog, ever)
Also might be obvious to most of you reading this, but realizing how most programs I initially found quite complicated boil down to setting list / dicts of elements, and iterating through them, applying some method, and that's it.
Anyways... It's 1AM - and not feeling like writing too much. This is a good example of "I wouldn't have coded today but did it anyway because I told myself I would do it for 6 weeks straight".
See you tomorrow, whoever is reading this!