bstoilov / py3-pinterest

Fully fledged Python Pinterest client
MIT License
297 stars 104 forks source link

Pinterest Login is broken (Due to pinterest API updates) #108

Open bstoilov opened 3 years ago

bstoilov commented 3 years ago

Pinterest included captcha verification. Changes to the login need to be applied in order to resolve this.

bstoilov commented 3 years ago

Users that still have valid sessions are not affected by this. There is currently a branch with quite a few changes that addresses the issue

https://github.com/bstoilov/py3-pinterest/tree/login-with-selenium

It would be great if you can help with testing

bstoilov commented 3 years ago

For anyone still having problems try upgrading to 1.2.1

DrunkCodes commented 3 years ago

I upgraded and it is forcing me to create a file path first.

FileNotFoundError: [WinError 3] The system cannot find the path specified: ''

But before the upgrade if you pass in empty string as the fill path, it will automatically create a folder in that directory that the python file is running.

I later gave it a file path but it keep giving errors

def multi_login(): for accts in section_b: pinterest = Pinterest(email=accts[0], password=accts[1], username=accts[2], cred_root='C:\Users\user\PycharmProjects\PinMonster\sectionb') pinterest.login()

multi_login()

this is the error cred_root='C:\Users\user\PycharmProjects\PinMonster\sectionb') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

can you give me an expample of the fill path syntax. also if it can create fill path by itself like before that will be great. For now I have not tested the main code

bstoilov commented 3 years ago

OK, I will look into it. Try using relative path for now. Like cred_root=sectionb

DrunkCodes commented 3 years ago

I have tested the latest update 1.2.1 This is my code def multi_login(): for accts in section_b: pinterest = Pinterest(email=accts[0], password=accts[1], username=accts[2], cred_root='sectionb') pinterest.login()

multi_login() But it was not able to login. This was the console message: C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/user/PycharmProjects/PinMonster/main.py No credentials stored [Errno 2] No such file or directory: 'sectionb\octaviavaughan848@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - There is no [win32] chromedriver for browser 87.0.4280 in cache [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Trying to download new driver from http://chromedriver.storage.googleapis.com/87.0.4280.88/chromedriver_win32.zip [WDM] - Driver has been saved in cache [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88] Failed to login Message:

No credentials stored [Errno 2] No such file or directory: 'sectionb\lynetteneal614@mail.ru' [WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280

[WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Failed to login Message:

No credentials stored [Errno 2] No such file or directory: 'sectionb\myrtlenevill409@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Failed to login Message:

No credentials stored [Errno 2] No such file or directory: 'sectionb\inpqrinbeqplvd@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Failed to login Message:

Process finished with exit code 0

What can I do about this.

bstoilov commented 3 years ago

try pinterest.login(headless=False). to see if it actually manages to login

DrunkCodes commented 3 years ago

I used the headless parameter , results: it poped up chrome browser which means it is not headless. then this is the console message

C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/user/PycharmProjects/PinMonster/main.py No credentials stored [Errno 2] No such file or directory: 'sectionb\octaviavaughan848@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Reading credential from sectionb\octaviavaughan848@mail.ru No credentials stored [Errno 2] No such file or directory: 'sectionb\lynetteneal614@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Reading credential from sectionb\lynetteneal614@mail.ru No credentials stored [Errno 2] No such file or directory: 'sectionb\myrtlenevill409@mail.ru' [WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280

[WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Failed to login Message:

No credentials stored [Errno 2] No such file or directory: 'sectionb\inpqrinbeqplvd@mail.ru'

[WDM] - Current google-chrome version is 87.0.4280 [WDM] - Get LATEST driver version for 87.0.4280 [WDM] - Driver [C:\Users\user.wdm\drivers\chromedriver\win32\87.0.4280.88\chromedriver.exe] found in cache Reading credential from sectionb\inpqrinbeqplvd@mail.ru

Process finished with exit code 0

what do you understand from this console message.

I don't know if we should switch to Selenium completely , am bit good in selenium, the only hard thing for me on Pinterest is to comment with selenium. I f we use Selenium a lot of limitations will be off and a lot of functions too will be off and it will take more time.

DrunkCodes commented 3 years ago

I think it was able to login three accounts from the four accounts that was in the list I pass to it. Also it didn't say account logged in and was not able to say that the credentials was saved or not. It makes it a bit hard to debug

DrunkCodes commented 3 years ago

I also tried to use one of the accounts that was logged in to do repin but it didn't work. This is the console message

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.pinterest.com/resource/RepinResource/create/

imgVOID commented 3 years ago

https://velog.io/@nickanism/Using-Selenium-to-Crawl-Web-Contents maybe u need to see this

oleg2k18 commented 3 years ago

im get error Failed to login Message: In debug mode too

bstoilov commented 3 years ago

I just tested on windows, all is fine.

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape means invalid escape char, this is caused by cred_root='C:\Users\user\PycharmProjects\PinMonster\sectionb since you are on windows you need to escape things the windows way C:\Users\user\PycharmProjects\PinMonster\sectionb

Probably none of the credentials were stored if you provided the paths like this.

Everyting is working on Mac OS as well. I will be closing this and all of its related issues.

tobeyond commented 2 years ago

I tested on Windows with headless=False. The script is not pressing the button to login. I clicked manually and it worked fine, but it 's still an issue.

bstoilov commented 2 years ago

They probably have changed the html and selenium can't find the button. I won't have time to fix this right now if someone can take a look it will be greatly appreciated

bstoilov commented 2 years ago

I just test it locally and was able to login just fine, can you check if you have any error in the browser console, also try updating chrome

tobeyond commented 2 years ago

Well, I found the issue. chrome_options.add_argument("--lang=en") was missing. My pinterest was not in english so driver.find_elements_by_xpath("//*[contains(text(), 'Log in')]") was not doing the trick. It's working fine now that I changed it locally.

Carnagency commented 4 months ago

I have tried a lot of the things that were discussed in all the different conversations of the repositery.

I was really hopeless and I found that it was simply due to me living in a non-english country so I just had to change the settings of my pinterest account and put US in country and american english in language.

Check this link out :

https://docs.contentstudio.io/article/497-pinterest-post-failed-to-publish#:~:text=Authorization%20Problem%3A%20If%20you%20are,the%20account%20to%20the%20English.

Also try to suppress the content of cred_root so that it fills up with updated and working data. Hope this will help some fellow coders !

Ashad001 commented 3 months ago

you are probably using newer version of selenium, so just change some lines in Pinterest.py

driver.find_element(by = By.ID, value='email').send_keys(self.email)
driver.find_element(by= By.ID, value="password").send_keys(self.password)
logins = driver.find_elements(by=By.XPATH, value="//*[contains(text(), 'Log in')]")

also make sure to import by

from selenium.webdriver.common.by import By

image