Jul-04-2018, 04:59 AM
I'm trying to log into globenewswire.com with requests on my reader account. After I log in I want to go to a page on my account that requires my login to access. I'm using this code to basically parse for news.
This is the url where im trying to log in from :https://login.globenewswire.com/?ReturnUrl=%2fReaderAccount%3frunSearchId%3d41894572&runSearchId=41894572#login
Here it is so far:
This is the url where im trying to log in from :https://login.globenewswire.com/?ReturnUrl=%2fReaderAccount%3frunSearchId%3d41894572&runSearchId=41894572#login
Here it is so far:
import requests import bs4 as bs url = 'https://login.globenewswire.com/?ReturnUrl=%2fReaderAccount%3frunSearchId%3d41894572&runSearchId=41894572#login' USER = 'myusernamehere' PASS = 'mypasswordhere' user_pass = { 'emailAddress': USER, 'password': PASS, } session = requests.Session() session.post(url, data=user_pass) r = session.get('https://globenewswire.com/Search?runSearchId=41894572') # The page on my account which requires login to access. soup = bs.BeautifulSoup(r.content, 'lxml') title_list = soup.find_all('p', class_="company-title") # Parsing for news titles. print(r.text) # Prints out source code just to see it. print('len(title_list) =', len(title_list)) # len(title_list) should be 10 if I run my code right, but it gives me 0.I understand that for every website logging in with requests is slightly different. I was able to get the names of the fields to post my username and password in, However, I don't know where to go from here. Do I have to send cookies? Am I posting wrong? P.S. My code is not explicitly giving an error, it just doesn't take me to the page I want to go. Any help is appreciated.