gpt4 book ai didi

python - 是否可以使用 webbrowser 或 Selenium 在浏览器中获取当前 URL

转载 作者:行者123 更新时间:2023-11-28 21:50:51 25 4
gpt4 key购买 nike

或者可能“破解”webbrowser 的实际库代码或 Selenium去做这个?我正在查看当前文档,但没有看到这是可能的,但也许您可以调整实际的库代码并插入此功能?

不幸的是,以下使用 Selenium 的方法不起作用 - 它只返回原始 URL:

import selenium
from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://api.instagram.com/oauth/authorize/?client_id=cb0096f08a387355f&redirect_uri=http://pythondev.instadev.com/instagramredirect.html&response_type=code")
print driver.current_url

最佳答案

不,但如果您正在寻找一个模块,让您可以更好地控制浏览器,请查看 selenium webdriver。

在 selenium 中函数是 driver.current_url

如 bob0the0mighty 的链接所示,您需要有一个循环来等待 url 更改。尝试类似的东西:initialurl="https://api.instagram.com/oauth/authorize/client_id=cb0096f08a387355f&redirect_uri=http://pythondev.instadev.com/instagramredirect.html&response_type=code"

currenturl="https://api.instagram.com/oauth/authorize/?client_id=cb0096f08a387355f&redirect_uri=http://pythondev.instadev.com/instagramredirect.html&response_type=code"/p>

同时(真):
如果(当前网址!=初始网址):
打印当前网址
中断

关于python - 是否可以使用 webbrowser 或 Selenium 在浏览器中获取当前 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31346121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com