Download File PyQT Browser [duplicate]
This question already has an answer here:
download file from qwebkit at pyqt
1 answer
Using Pyqt4 to download thousands of PDF's from URL
1 answer
How can I download a file using this browser, when you click on links it does nothing. Everything else works fine, it loads the pages perfectly and can upload files, everything else is working perfectly, I just need a way to download files from links. Thank you in advance. :)
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
def _return_pressed(self):
browser.setHtml('Loading...')
data = self.text()
url = QUrl(data)
browser.load(url)
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
Here is the solution to my porblem:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4 import QtNetwork
from PyQt4 import QtGui
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
import Tkinter, tkFileDialog
import sys
import os
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
self.browser.page().setForwardUnsupportedContent(True)
self.browser.page().unsupportedContent.connect(self.download)
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.finished)
def _return_pressed(self):
data = self.text()
url = QUrl(data)
browser.load(url)
def download(self, reply):
self.request = QtNetwork.QNetworkRequest(reply.url())
self.reply = self.manager.get(self.request)
def finished(self):
filename = str(self.reply.url().path()).split('/')[-1]
root = Tkinter.Tk()
root.withdraw()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/Desktop",title='You are downloading a file, please select a directory to place the file. Close the window to cancel')
if dirname.strip() != '':
dirname = dirname.replace('/','\')
f = open(dirname+'\'+filename,'wb')
f.write(str(self.reply.readAll()))
f.close()
else:
pass
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
python pyqt4
marked as duplicate by Maurice Meyer, eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 13 more comments
This question already has an answer here:
download file from qwebkit at pyqt
1 answer
Using Pyqt4 to download thousands of PDF's from URL
1 answer
How can I download a file using this browser, when you click on links it does nothing. Everything else works fine, it loads the pages perfectly and can upload files, everything else is working perfectly, I just need a way to download files from links. Thank you in advance. :)
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
def _return_pressed(self):
browser.setHtml('Loading...')
data = self.text()
url = QUrl(data)
browser.load(url)
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
Here is the solution to my porblem:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4 import QtNetwork
from PyQt4 import QtGui
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
import Tkinter, tkFileDialog
import sys
import os
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
self.browser.page().setForwardUnsupportedContent(True)
self.browser.page().unsupportedContent.connect(self.download)
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.finished)
def _return_pressed(self):
data = self.text()
url = QUrl(data)
browser.load(url)
def download(self, reply):
self.request = QtNetwork.QNetworkRequest(reply.url())
self.reply = self.manager.get(self.request)
def finished(self):
filename = str(self.reply.url().path()).split('/')[-1]
root = Tkinter.Tk()
root.withdraw()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/Desktop",title='You are downloading a file, please select a directory to place the file. Close the window to cancel')
if dirname.strip() != '':
dirname = dirname.replace('/','\')
f = open(dirname+'\'+filename,'wb')
f.write(str(self.reply.readAll()))
f.close()
else:
pass
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
python pyqt4
marked as duplicate by Maurice Meyer, eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22
|
show 13 more comments
This question already has an answer here:
download file from qwebkit at pyqt
1 answer
Using Pyqt4 to download thousands of PDF's from URL
1 answer
How can I download a file using this browser, when you click on links it does nothing. Everything else works fine, it loads the pages perfectly and can upload files, everything else is working perfectly, I just need a way to download files from links. Thank you in advance. :)
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
def _return_pressed(self):
browser.setHtml('Loading...')
data = self.text()
url = QUrl(data)
browser.load(url)
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
Here is the solution to my porblem:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4 import QtNetwork
from PyQt4 import QtGui
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
import Tkinter, tkFileDialog
import sys
import os
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
self.browser.page().setForwardUnsupportedContent(True)
self.browser.page().unsupportedContent.connect(self.download)
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.finished)
def _return_pressed(self):
data = self.text()
url = QUrl(data)
browser.load(url)
def download(self, reply):
self.request = QtNetwork.QNetworkRequest(reply.url())
self.reply = self.manager.get(self.request)
def finished(self):
filename = str(self.reply.url().path()).split('/')[-1]
root = Tkinter.Tk()
root.withdraw()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/Desktop",title='You are downloading a file, please select a directory to place the file. Close the window to cancel')
if dirname.strip() != '':
dirname = dirname.replace('/','\')
f = open(dirname+'\'+filename,'wb')
f.write(str(self.reply.readAll()))
f.close()
else:
pass
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
python pyqt4
This question already has an answer here:
download file from qwebkit at pyqt
1 answer
Using Pyqt4 to download thousands of PDF's from URL
1 answer
How can I download a file using this browser, when you click on links it does nothing. Everything else works fine, it loads the pages perfectly and can upload files, everything else is working perfectly, I just need a way to download files from links. Thank you in advance. :)
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
def _return_pressed(self):
browser.setHtml('Loading...')
data = self.text()
url = QUrl(data)
browser.load(url)
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
Here is the solution to my porblem:
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
from PyQt4 import QtNetwork
from PyQt4 import QtGui
from PyQt4.QtGui import QGridLayout, QLineEdit, QWidget
import Tkinter, tkFileDialog
import sys
import os
class UrlInput(QLineEdit):
def __init__(self, browser):
super(UrlInput, self).__init__()
self.browser = browser
self.returnPressed.connect(self._return_pressed)
self.browser.page().setForwardUnsupportedContent(True)
self.browser.page().unsupportedContent.connect(self.download)
self.manager = QtNetwork.QNetworkAccessManager()
self.manager.finished.connect(self.finished)
def _return_pressed(self):
data = self.text()
url = QUrl(data)
browser.load(url)
def download(self, reply):
self.request = QtNetwork.QNetworkRequest(reply.url())
self.reply = self.manager.get(self.request)
def finished(self):
filename = str(self.reply.url().path()).split('/')[-1]
root = Tkinter.Tk()
root.withdraw()
dirname = tkFileDialog.askdirectory(parent=root,initialdir="/Desktop",title='You are downloading a file, please select a directory to place the file. Close the window to cancel')
if dirname.strip() != '':
dirname = dirname.replace('/','\')
f = open(dirname+'\'+filename,'wb')
f.write(str(self.reply.readAll()))
f.close()
else:
pass
if __name__ == "__main__":
app = QApplication(sys.argv)
grid = QGridLayout()
browser = QWebView()
url_input = UrlInput(browser)
grid.addWidget(url_input, 1, 0)
grid.addWidget(browser, 2, 0)
main_frame = QWidget()
main_frame.setLayout(grid)
main_frame.show()
sys.exit(app.exec_())
This question already has an answer here:
download file from qwebkit at pyqt
1 answer
Using Pyqt4 to download thousands of PDF's from URL
1 answer
python pyqt4
python pyqt4
edited Nov 22 '18 at 19:31
Vaxe
asked Nov 21 '18 at 22:12
VaxeVaxe
14
14
marked as duplicate by Maurice Meyer, eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Maurice Meyer, eyllanesc
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22
|
show 13 more comments
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22
|
show 13 more comments
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
I tried this but I don't understand how to do it, I saw where I can call a funtion with the Request, but I dont know what to do in that function.
– Vaxe
Nov 21 '18 at 23:07
I made an edit to show the download function.
– Vaxe
Nov 21 '18 at 23:09
your question is equivalent to "how to do X" ?, and the solution is in the link, instead it seems that you want to ask "I tried Y to do X but it does not work", so for that case it is necessary that Y be a a Minimal, Complete, and Verifiable example and its code is not. please take the time and provide a MCVE in addition to the url since this type of questions is very dependent on the url.
– eyllanesc
Nov 21 '18 at 23:11
The solutions not in the link i littearlly said I dont understand it isnt that the whole point of your website?
– Vaxe
Nov 21 '18 at 23:22
I had already seen that before and I did not understand it SO i came here I do not know how to use what the answer was in my code
– Vaxe
Nov 21 '18 at 23:22