我是硒的新手。
我想使用Python登录该网站:http://www.truecaller.com

到目前为止,这是我拥有的代码:

from selenium import webdriver

browser = webdriver.Firefox()
browser.get('http://www.truecaller.com/sign-in/yahoo')
browser.find_element_by_name('username').send_keys('name')
browser.find_element_by_name('passwd').send_keys("pass\n")


它确实已登录,但告诉我“已登录”,但未重定向。我已经尝试了一切。我不明白

最佳答案

您正在朝着正确的方向前进。

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait

# Initializing firefox browser
browser = webdriver.Firefox()

# Initializing login to Yahoo
browser.get('http://www.truecaller.com/sign-in/yahoo')

browser.find_element_by_name('username').send_keys('name')
browser.find_element_by_name('passwd').send_keys("pass\n")
browser.find_element_by_id("login-signin").click()

# Wait till browser is logged in to Yahoo, will throw error after 20 secs.
wait = WebDriverWait(browser, 20)
wait.until(lambda driver: driver.current_url == "http://www.truecaller.com/sign-in/yahoo")


我编写了一个脚本来从TrueCaller中删除号码详细信息。仅适用于Yahoo登录


https://github.com/sumansaurabh/TrueCallerAPi/blob/cliTrueCaller/trueCaller.py通过运行脚本来获取数字详细信息。
https://github.com/sumansaurabh/TrueCallerAPi Flask服务器以部署应用程序并获取电话号码详细信息。

关于python - 如何编写一个可以登录该网站并维护 session 信息的python脚本?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27929669/

10-16 22:06