mirror of https://github.com/vitalif/phantomjs
parent
4d2fedf243
commit
9da842df2b
|
@ -407,6 +407,29 @@ bool Phantom::injectJs(const QString &jsFilePath)
|
|||
return Utils::injectJsInFrame(pre + jsFilePath, libraryPath(), m_page->mainFrame());
|
||||
}
|
||||
|
||||
void Phantom::setProxy(const QString &ip, const qint64 &port, const QString &proxyType, const QString &user, const QString &password)
|
||||
{
|
||||
qDebug() << "Set " << proxyType << " proxy to: " << ip << ":" << port;
|
||||
if (ip.isEmpty()) {
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
}
|
||||
else {
|
||||
QNetworkProxy::ProxyType networkProxyType = QNetworkProxy::HttpProxy;
|
||||
|
||||
if (proxyType == "socks5") {
|
||||
networkProxyType = QNetworkProxy::Socks5Proxy;
|
||||
}
|
||||
// Checking for passed proxy user and password
|
||||
if(!user.isEmpty() && !password.isEmpty()) {
|
||||
QNetworkProxy proxy(networkProxyType, ip, port, user, password);
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
} else {
|
||||
QNetworkProxy proxy(networkProxyType, ip, port);
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Phantom::exit(int code)
|
||||
{
|
||||
if (m_config.debug()) {
|
||||
|
|
|
@ -168,6 +168,15 @@ public slots:
|
|||
*/
|
||||
void clearCookies();
|
||||
|
||||
/**
|
||||
* Set the application proxy
|
||||
* @brief setProxy
|
||||
* @param ip The proxy ip
|
||||
* @param port The proxy port
|
||||
* @param proxyType The type of this proxy
|
||||
*/
|
||||
void setProxy(const QString &ip, const qint64 &port = 80, const QString &proxyType = "http", const QString &user = NULL, const QString &password = NULL);
|
||||
|
||||
// exit() will not exit in debug mode. debugExit() will always exit.
|
||||
void exit(int code = 0);
|
||||
void debugExit(int code = 0);
|
||||
|
|
Loading…
Reference in New Issue