简体   繁体   English

instagram 上的 Selenium 模块出错(抓取)

[英]Error with Selenium module on instagram (scraping)

i have a problem with this bit of code:我对这段代码有疑问:

from selenium import webdriver
driver = webdriver.Chrome(executable_path="E:\Hack\chromedriver_win32\chromedriver.exe")
driver.get("https://www.instagram.com/")
user_name=driver.find_element_by_xpath('//*[@id="loginForm"]/div/div[1]/div/label/input')
user_name.send_keys('user_name')

Now the problem is that the script cant find the username/pasword input fields on https://www.instagram.com/.. .现在的问题是脚本在https://www.instagram.com/..上找不到用户名/密码输入字段。 I tried through name, class, XPath or whatever it's called but othing.我尝试了名称,class,XPath 或其他任何名称。 It just doesnt want to work?它只是不想工作? Can anyone find a solution to this pls: :(任何人都可以找到解决这个问题的方法::(

You are probably looking for the page: https://www.instagram.com/accounts/login/您可能正在寻找以下页面: https://www.instagram.com/accounts/login/

Your Xpath also doesn't seem too correct.您的 Xpath 似乎也不太正确。

try on the page I sent with this one试试我用这个发送的页面

driver.find_element_by_xpath('//input[@type="text"]')

You may come to another problem on Instagram.您可能会在 Instagram 上遇到另一个问题。 They have ways of detecting the Webdriver and they simply redirect you to a page where you have to perform tasks to prove you are a human and not a computer.他们有检测 Webdriver 的方法,他们只是将您重定向到您必须执行任务以证明您是人而不是计算机的页面。 You may need to create headers and work arounds to access the login page without many problems.您可能需要创建标题和解决方法才能访问登录页面而不会出现很多问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM