Skip to content

Commit

Permalink
proxy support for login
Browse files Browse the repository at this point in the history
  • Loading branch information
bstoilov committed Dec 16, 2020
1 parent fbcdd05 commit 469b799
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion py3pin/Pinterest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion py3pin/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.0'
__version__ = '1.2.1'

0 comments on commit 469b799

Please sign in to comment.