I am trying to write a progam that is supposed to open random links in my browser, using the webbrowser module and the random module. I am also using a .txt file where all the links are saved. I have the browser defined as:
firefox = webbrowser.Mozilla("C:\\Program Files\
\\Mozilla Firefox\\firefox.exe")
The part of selecting random links work. Here the text document:
"https://youtube.com"
"https://google.com"
"https://spotify.com"
"https://epicgames.com"
"https://stackoverflow.com"
I defined the whole thing as a command because I want to use it later in the program agian.
def photoids():
htlp1 = linecache.getline("photoids.txt", randint(1,5))
print(htlp1)
firefox.open(htlp1)
htlp1 is the string with a link.
Now when starting the program, the link that is printed in the console window is:
"https://youtube.com"
but in my browser, the following is enterd into the URL bar:
file:///C:/Users/[my username]/source/repos/PythonApplication2/PythonApplication2%00/%22https://youtube.com%22
I dont know why, as the string htlp1 is clearly right when printed, but spits out a path to the file location with the link attached to it at the end when opened using the webbrowser module. I dont know why the webbrowser does not want to just open with that link or why the webbrowser thinks that htlp1 should not be a string. I think I am going insane, wasting hours on that little problem...