web scrape through an input form

133 Views Asked by At

I'm a beginner to web scraping and although I can do it to an average webpage, I've tried in both node.js and python to scrape Solarwinds but it only returns the login page despite giving the correct login credentials.

import mechanize
from bs4 import BeautifulSoup
import urllib2 
import cookielib

cj = cookielib.CookieJar()
br = mechanize.Browser()
br.set_handle_robots(False)
br.set_cookiejar(cj)
br.open("******")



br.select_form(nr=0)
br.form['username'] = '***'
br.form['password'] = '***'
br.submit()

print br.response().read()

I always get this error mechanize._form.ControlNotFoundError: no control matching name 'username'

0

There are 0 best solutions below