Python Forum
How to open a list of websites
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to open a list of websites
#1
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
#2
Works ok for me on Windows, maybe there is a blank line at the end of your text file or something like that ?
#3
use: page = browser.page_source
to get browser contents
#4
(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.
#5
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs



Possibly Related Threads…
Thread Author Replies Views Last Post
  Is chromedriver detectable by heavy seured websites? kolarmi19 4 1,447 Mar-29-2022, 08:14 PM
Last Post: Larz60+
  How to open MIDI-file and get events in a list? philipbergwerf 7 4,853 May-29-2021, 08:24 AM
Last Post: j.crater
  how to open program file .exe from list SayHiii 2 2,395 Dec-11-2019, 01:28 AM
Last Post: SayHiii

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020