#πŸ”’ I want to open a url in a private firefox window with the webbrowser module

42 messages Β· Page 1 of 1 (latest)

sterile void
#

I can't seem to find how to open a url in a private window. I've tried with chatGPT and stackoverflow but it just doesn't work. It either doesn't do anything, gives me an error or opens it in a normal window. I think webbrowser will be the best way to do it but if you have a better idea, feel free to let me know. I will be very glad if you could help me!

inner driftBOT
#

@sterile void

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eternal whale
#

if you know where the firefox install is

#

you could launch it yourself with firefox -private from the command line

#

if you are on a linux like system, you could use the whereis command

root~$ whereis firefox
firefox: /usr/bin/firefox /etc/firefox /snap/bin/firefox
sterile void
#

But I want to do it with python to automate it

eternal whale
sterile void
#

Yes

eternal whale
#

do you just want to load one singular webpage?

sterile void
#

I've tried to do it with the webbrowser module and it does it but it opens it in a normal browser even tho I add the '-private' or incognito or whatever

sterile void
eternal whale
#

I mean, if it's just one website

#
import os

URL = 'example.com'
os.system( "firefox -private '" + URL + "'" )
sterile void
#

It says Firefox is not recognized

#

Do I need to add the path

eternal whale
#

yeahh

sterile void
#

here's what i have for now

eternal whale
#

also add https://

#

I have accidentally given you the wrong command line option

#

the correct option is

#

firefox -private-window $URL

#

replace $URL with your website

#

in quotes

#

root~$ firefox -private-window "https://www.youtube.com"

sterile void
#

so it should become:
os.system(f"{firefox_path} -private '" + url + "'")

eternal whale
#

oh my gawd f strings

#

i do not how to use them

#

😭

eternal whale
#

it should be good

sterile void
#

thanks

eternal whale
#

also

#

private-window

#

not private

#

change it mkay?

sterile void
#

yeah

eternal whale
#

notify me if it works

sterile void
#

ok

#

!close

inner driftBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.