Python Forum
How to open a list of websites - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to open a list of websites (/thread-34407.html)



How to open a list of websites - Tyrel - Jul-28-2021

Could someone please help,

web_value.txt:
http://google.com
http://YouTube.com
openwebsites.py:

import webbrowser
import os


def websites():
    websitelist = "Setup1\\web_value.txt"
    websites = []
    browser = webbrowser.get("windows-default")
    for line in open(websitelist, "r").readlines():
        websites.append(line.strip())
    for website in websites:
        browser.open(website)
websites()
The script opens the websites in my browser and it works perfectly but it also keeps opening the directory of openwebsites.py in file explorer. Is there a way I can get the list of websites from the file and open them in the browser without opening the directory of openwebsites.py in file explorer also. I’m using VSCode


RE: How to open a list of websites - steve_shambles - Aug-05-2021

Works ok for me on Windows, maybe there is a blank line at the end of your text file or something like that ?


RE: How to open a list of websites - Larz60+ - Aug-05-2021

use: page = browser.page_source
to get browser contents


RE: How to open a list of websites - snippsat - Aug-05-2021

(Aug-05-2021, 09:54 AM)Larz60+ Wrote: use: page = browser.page_source
to get browser contents
This is not Selenium Larz60+ Wink

So it's a duplicate of this Thread .
(Jul-28-2021, 09:03 PM)Tyrel Wrote: but it also keeps opening the directory of openwebsites.py in file explorer
How do you run this code❔
There is no way i get file explorer to open when i run this code.
It's not a normal behavior as i have run webbrowser on different Pc and Windows version and never has file explorer opened.


RE: How to open a list of websites - buran - Aug-06-2021

Please, don't start multiple threads for the same problem. I will now close this thread. Please, keep the discussion in the original thread
https://python-forum.io/thread-34393.html