问题描述
我正在使用Python + Selenium构建Instagram机器人,并且尝试获取元素(如like按钮)的fill属性,并在like_color!=“”#262626“的情况下使该机器人喜欢它
此代码的目的是避免取消喜欢的帖子。
x7 = '//*[@id="react-root"]/section/main/div/div[1]/article/div[3]/section[1]/span[1]/button/div'
like_color = driver.find_element_by_xpath(x7).get_attribute("fill")
# #262626 means that the color is grey (not liked)
if like_color == '#262626':
# like_post() is the function that gives likes
like_post()
else:
print('Post already liked')
我和其他许多人都尝试过这种方式,但是仍然没有结果..当我要求输入代码
print(like_color)
它返回“无”
如果您有任何知识,请帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)