If I have a .txt file containing a list of URLs, how can I get Chrome or Firefox to open them, one URL per tab and then save the page in each tab separately?
Any platform will do: Windows, Mac, Linux.
25 Answers
Opening the URLs in tabs can be done just pasting in a console prompt cmd your URLs like this.
start chrome &
start chrome &
.
.
.or
start firefox &
start firefox &
.
.
. 1 Although the question specifically mentions Chrome and Firefox, if what you are trying to do is to save the content of each page, wget is made for this task. E.g.:
wget --input-file=list_of_urls.txtYou can even specify a specific user-agent in case you want the server to see the request as a certain browser:
wget --user-agent=some_specific_user_agent_string --input-file=list_of_urls.txt Answering my own question, I was unsure of some plug-ins I had already seen but a closer look confirmed that they should do the job.
Two stages:
1) Run Firefox or Chrome from the command line, passing in the list of sites as parameter or a file containing a list, using one of the following methods:
- How to open a list of URLs in Firefox or SeaMonkey?
- How to open a set of tabs together quickly?
- Chrome command line arguments w/ url?
2) Then use one of the following plug-in as appropriate to save all the contents of each tab
Firefox:
Quoted from the plug-in page (particular features of interest for this question):
About this Add-on: UnMHT provides following features:
- Save webpage as MHT file.
- Insert URL of the webpage and date you saved into saved MHT file.
- Save multiple tabs as MHT files at once.
- Save multiple tabs into a single MHT file.
- Save webpage by single click into prespecified directory with Quick Save feature.
- Convert HTML files and directory which contains files used by the HTML into MHT file.
- View the MHT file saved by UnMHT, IE, PowerPoint, etc.
Chrome:Extension: ZipTabs
From the extension page:
- save multiple opened pages into a zip file containing single HTML files with all resources included (images, stylesheets, frames...)
- open a zip file containing archives into tabs Notes:
- this extension needs "SingleFile Core" to be already installed (follow install instructions)
Getting all of the tabs to open separate through batch isn't too hard.
Code:
@echo off
open chrome [enter URL 1]
open chrome [enter URL 2]
...
exitAs for the saving, not sure if it's possible through batch. I could be wrong though.
Open all at once one on each tab from the command line (CLI)
Chromium:
xargs chromium-browser --new-tab < urls.txtFirefox:
xargs -L1 firefox -new-tab < urls.txtor slightly more efficiently as per:
xargs printf -- '-new-tab %s\n' < urls.txt | xargs firefoxTest file:
urls.txt
Firefox needs a bit more work because it requires one -new-tab for every URL:
firefox -new-tab \ -new-tab \ -new-tab For the saving, you should just use wget instead of a browser as mentioned at:
Tested on Ubuntu 20.10, Firefox 84, Chromium 85.
Web-based URL openers
There are several JavaScript based services out there, e.g. which are a good newb-proof solution that don't require installing anything.
You just paste the list of URLs into them, click "Open All", and they open one URL per tab.
You have to enable popups/multi-tab opening for the domain however, as those are blocked by default on most browsers to prevent ad spam. Browsers usually show a "Popup blocked" warning, which you can then click to disable.
TODO can't find an open source one on GitHub pages after searching for five minutes...
Related:
1