简体   繁体   English

使用Python和网络机器人获取当前URL

[英]Get current URL using Python and webbot

Is there a way to get the current url using webbot? 有没有一种方法可以使用Webbot获取当前网址? I looked at ways using os.environ , but it didn't work for me. 我研究了使用os.environ ,但是它对我不起作用。 I need the url of the page I am opening using webbot.Browser() , because some links are redirected and change. 我需要使用webbot.Browser()打开的页面的URL,因为某些链接已重定向和更改。

you can use get_current_url(). 您可以使用get_current_url()。 Consider the following example: 考虑以下示例:

from webbot import Browser
web = Browser()
url = 'something.com' # site name
web.go_to(url)
... #your code
webbot_result_url = web.get_current_url()
print(webbot_result_url )

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

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