python - 如何从 Instagram 上的个人资料转到最近的帖子
问题描述
因此,我正在尝试制作一个程序,该程序可以自动在用户的所有 instagram 帖子下使用 selenium 进行评论。
但是我尝试过的所有 XPath 都不要去他们最近的帖子,他们什么都不做!
我的代码:
import os
import time
from colorama import *
from selenium import webdriver as wd
from selenium.webdriver.chrome.options import Options
import time
from time import sleep
init()
def main(username, password, target):
while True:
options = Options()
options.headless = False # Chrome Headless
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = wd.Chrome('chromedriver.exe', options=options)
driver.get("https://www.instagram.com/accounts/login/?source=auth_switcher")
driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div[2]/button[1]').click()
sleep(2)
driver.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div/div[1]/div/label/input").send_keys(username)
driver.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div/div[2]/div/label/input").send_keys(password)
driver.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div/div[3]/button").click()
time.sleep(4)
driver.get("https://www.instagram.com/%s/" % target)
sleep(3)
print("Reporting")
driver.find_element_by_xpath("/html/body/div[1]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]/a/div[1]/div[1]")
def info():
os.system('cls')
print(Fore.LIGHTGREEN_EX + logo + Fore.RESET)
username = input(Fore.LIGHTBLUE_EX + 'Username: @' + Fore.LIGHTGREEN_EX)
password = input(Fore.LIGHTBLUE_EX + 'Password: ' + Fore.LIGHTGREEN_EX)
target = input(Fore.LIGHTBLUE_EX + 'Target: @' + Fore.LIGHTGREEN_EX)
main(username, password, target)
print(Fore.LIGHTGREEN_EX + logo + Fore.RESET)
info()
我在这个网站上很新,请不要介意,但我是否做错了什么,我应该从他们的个人资料中做,还是我愚蠢?
解决方案
尝试使用响应式设计模式。Windows 中的 CTRL-Shift-M。
推荐阅读
- python - 如何在 Python 中用 np.linalg.norm 替换 scipy.spatial.distance
- java - 将 cxf-spring-boot-starter-jaxrs WebClient 与 TLS 一起使用会产生证书未知错误
- performance - 可以在 Google Cloud Platform 上运行的“perf”替代性能管理工具
- snowflake-cloud-data-platform - 更改 Snowflake 中已删除表的数据保留
- c - 为什么 Windows Defender 将编译的 C 可执行文件检测为病毒?
- javascript - 类型错误:Vue.js 中的“_vm.KisanData 未定义”
- r - Reticulate 找不到 Anaconda 安装
- swift - 如何使 CAshapeLayer 适合按钮?
- javascript - 我可以使用哪种图表来使用 ChartJS(或类似的)来实现这一点?
- c++ - 如何完全禁用 qtableview 的选择(对于所有单元格)?