Please Help - Auto-Login - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Please Help - Auto-Login (/thread-5761.html) |
Please Help - Auto-Login - shiny - Oct-20-2017 Good Day, I'm working on Auto-LogIn for the flowing webpage. I'm very new to the Python; and I have been following a YouTube tutorial. I need help to review my code. import re from robobrowser import RoboBrowser br = RoboBrowser() br.open("https://m.onlinebrokerage.cibc.com/#/signOn/en/ie") form = br.get_form() form['ng-pristine ng-valid ng-touched'] = "****" form['field ng-pristine ng-valid ng-valid-maxlength ng-touched'] = "****" br.submit_form(form) src = str(br.parsed()) start = '<span class="S27">' end = '</span>' result = re.search('%s(.*)%s' % (start, end), src).group(1) print(result)My errors: what should I replace 'ng-pristine ng-valid ng-touched' with? This field has no IDAnd I'm Not sure what's wrong with line 7 please help RE: Please Help - Auto-Login - snippsat - Oct-20-2017 You are not getting the form,so it return None. >>> form = None >>> form['something'] = '****' The problem here is that log in use JavaScripts here with AngularJS.RoboBrowser dos not evaluate JavaScript,so then have to reverse engineering what Angular dos to do the same. Or simpler use Selenium/PhantomJS to do this. Example it will try to log in: from selenium import webdriver from bs4 import BeautifulSoup import time # Activate Phantom and deactivate Chrome to not load browser #browser = webdriver.PhantomJS() browser = webdriver.Chrome() web_url = 'https://m.onlinebrokerage.cibc.com/#/signOn/en/ie' browser.get(web_url) user_name = browser.find_element_by_xpath('//input[@ng-model="pageState.username.value"]') user_name.send_keys("Foo") password = browser.find_element_by_xpath('//input[@ng-model="pageState.password.value"]') password.send_keys("Bar") time.sleep(2) submit = browser.find_element_by_css_selector('#submitButton') submit.click() ''' # Give source code to BeautifulSoup soup = BeautifulSoup(browser.page_source, 'lxml') welcome = soup.select('//title') print(welcome.text) ''' |