I have a list containing a number of URLs in string format.
url_list=['www.url1.com', 'www.url2.com', 'www.url3.com', 'www.url4.com']
I can print the urls to pdf individually, but I want to know how to loop through a list of urls and repeat the process over again. I have tried using a for loop but it does not work.
import sys
from PyQt5 import QtWidgets, QtWebEngineWidgets
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QPageLayout, QPageSize
from PyQt5.QtWidgets import QApplication
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
loader = QtWebEngineWidgets.QWebEngineView()
loader.setZoomFactor(1)
layout = QPageLayout()
layout.setPageSize(QPageSize(QPageSize.A4Extra))
layout.setOrientation(QPageLayout.Portrait)
loader.load(QUrl(url_list[0]))
loader.page().pdfPrintingFinished.connect(lambda *args: QApplication.exit())
def emit_pdf(finished):
loader.page().printToPdf(f"{number}_url_file.pdf", pageLayout=layout)
loader.loadFinished.connect(emit_pdf)
sys.exit(app.exec_())