diff --git a/README.md b/README.md index 396697d..6ab1d23 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ Pinterest(email='emai', password='pass', username='name', cred_root='cred_root', # The following features are currently supported ## Login/Logout -## NOTE: Pinterest integrated google recaptcha. This means we have to use webdriver to login. For that reason you must have chrome installed on you computer, in order for the login to work. +## NOTE: Pinterest integrated google recaptcha. This means we have to use web driver to login. For that reason you must have chrome installed on you computer, in order for the login to work. +### If you want to use many accounts, you should associate proxy with each one of them and login only with that proxy +### pinterest.login(proxy='ip_address:port') Login will store auth cookies for later use. These cookies are usually valid for ~15 days, then you will start getting 403 and 401 errors, which means you need to call login again. ## Login Login is required to permit actions to the Pinterest servers. Login will store auth cookies for later use. These cookies are usually valid for ~15 days, then you will start getting 403 and 401 errors, which means you need to call login again. diff --git a/py3pin/Pinterest.py b/py3pin/Pinterest.py index 6d83f2d..8f8e9db 100644 --- a/py3pin/Pinterest.py +++ b/py3pin/Pinterest.py @@ -15,6 +15,7 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.proxy import Proxy, ProxyType AGENT_STRING = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) " \ "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" @@ -113,7 +114,7 @@ def get(self, url): def post(self, url, data=None, files=None, headers=None): return self.request('POST', url=url, data=data, files=files, extra_headers=headers) - def login(self, headless=True, wait_time=15): + def login(self, headless=True, wait_time=15, proxy=None): """ Logs user in with the provided credentials User session is stored in the 'cred_root' folder @@ -126,6 +127,14 @@ def login(self, headless=True, wait_time=15): if headless: chrome_options.add_argument("--headless") + if proxy is not None: + http_proxy = Proxy() + http_proxy.proxy_type = ProxyType.MANUAL + http_proxy.http_proxy = proxy + http_proxy.socks_proxy = proxy + http_proxy.ssl_proxy = proxy + http_proxy.add_to_capabilities(chrome_options) + driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options) driver.get("https://pinterest.com/login") diff --git a/py3pin/__version__.py b/py3pin/__version__.py index 58d478a..3f262a6 100644 --- a/py3pin/__version__.py +++ b/py3pin/__version__.py @@ -1 +1 @@ -__version__ = '1.2.0' +__version__ = '1.2.1'