使用python从浏览器获取当前URL [英] Get current URL from browser using python

查看:1170
本文介绍了使用python从浏览器获取当前URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个HTTP服务器,该服务器根据浏览器URL中的尺寸提供位图,即 localhost://image_x120_y30.bmp 。我的服务器正在无限循环中运行,我想在用户请求BITMAP时获取URL,最后我可以从URL中提取图像尺寸。

I am running an HTTP server which serves a bitmap according to the dimensions in the browser URL i.e localhost://image_x120_y30.bmp. My server is running in infinite loop and I want to get the URL any time user requests for BITMAP, and at the end I can extract the image dimensions from the URL.

问题在这里询问:

如何在python网页中获取当前URL?

无法解决我的问题,因为我正在无限循环中运行,并且我想继续获取当前URL,以便可以将请求的BITMAP传递给用户。

does not address my problem as I am running in infinite loop and I want to keep on getting the current URL so I can deliver the requested BITMAP to the user.

推荐答案

如果要使用Selenium进行网络导航:

If to use Selenium for web navigation:

from selenium import webdriver
driver = webdriver.Firefox()
print (driver.current_url)

这篇关于使用python从浏览器获取当前URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆