# -*- coding: utf-8 -*- from bs4 import BeautifulSoup import requests import mechanize import mechanicalsoup import http.cookiejar import html2text from mechanize import Browser browser = Browser() #Create a browser object URL = 'https://w...content-available-to-author-only...n.com/login.aspx' CompanyName = "esko-india"# email login password = "Tukudude16@#" UserName = "ekma" # without @ browser = mechanize.Browser() browser.set_handle_robots(False) # no robots browser.addheaders = [('User-agent', 'Chrome')] response = browser.open(URL) print response.read() for form in browser.forms(): print "Form name:", form.name print form # print browser.form.control # for control in browser.form.control: # print control # print "type=%s, name=%s value=%s" % (control.type, control.name, browser[control.name]) # browser.select_form('form1') #response = browser.openurl('https://w...content-available-to-author-only...n.com/eleave/phistory.ASP?WhatRole=NONE&rnd=941137528418219221776723987672889231') #print("response data %s"%(response)) # Select the form browser.select_form(nr=0) browser['CompanyName'] = CompanyName browser.form['password'] = password browser.form['UserName'] = UserName response = browser.submit() print("login info %s "%(response.info())) # print("login response %s "%(browser.response().read())) # for form in browser.forms(): # print "Form name:", form.name # print form newOutput = browser.open('https://w...content-available-to-author-only...n.com/framegrabber.asp?body=/eleave/default.asp?rnd=178038120269322460430860711135637759&companyID=esko-india&userGuid=8A5F4C6F90B6447EA3190679323F1DBB') print("second page data %s "%(browser.response().read())) # Get response #suserPage = BeautifulSoup(response, 'html.parser') #print("mechanize output %s"%(response.get_data()))
Standard input is empty
prog.cpp:1:3: error: invalid preprocessing directive #-
# -*- coding: utf-8 -*-
^
prog.cpp:14:2: error: invalid preprocessing directive #Create
#Create a browser object
^~~~~~
prog.cpp:15:7: warning: character constant too long for its type
URL = 'https://www.justlogin.com/login.aspx'
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:16:27: error: stray ‘#’ in program
CompanyName = "esko-india"# email login
^
prog.cpp:18:19: error: stray ‘#’ in program
UserName = "ekma" # without @
^
prog.cpp:18:29: error: stray ‘@’ in program
UserName = "ekma" # without @
^
prog.cpp:20:34: error: stray ‘#’ in program
browser.set_handle_robots(False) # no robots
^
prog.cpp:21:24: warning: character constant too long for its type
browser.addheaders = [('User-agent', 'Chrome')]
^~~~~~~~~~~~
prog.cpp:21:38: warning: character constant too long for its type
browser.addheaders = [('User-agent', 'Chrome')]
^~~~~~~~
prog.cpp:30:3: error: invalid preprocessing directive #print
# print browser.form.control
^~~~~
prog.cpp:31:3: error: invalid preprocessing directive #for
# for control in browser.form.control:
^~~
prog.cpp:32:7: error: invalid preprocessing directive #print
# print control
^~~~~
prog.cpp:33:7: error: invalid preprocessing directive #print
# print "type=%s, name=%s value=%s" % (control.type, control.name, browser[control.name])
^~~~~
prog.cpp:34:3: error: invalid preprocessing directive #browser
# browser.select_form('form1')
^~~~~~~
prog.cpp:35:2: error: invalid preprocessing directive #response
#response = browser.openurl('https://www.justlogin.com/eleave/phistory.ASP?WhatRole=NONE&rnd=941137528418219221776723987672889231')
^~~~~~~~
prog.cpp:36:2: error: invalid preprocessing directive #print
#print("response data %s"%(response))
^~~~~
prog.cpp:39:3: error: invalid preprocessing directive #Select
# Select the form
^~~~~~
prog.cpp:41:9: warning: character constant too long for its type
browser['CompanyName'] = CompanyName
^~~~~~~~~~~~~
prog.cpp:42:14: warning: character constant too long for its type
browser.form['password'] = password
^~~~~~~~~~
prog.cpp:43:14: warning: character constant too long for its type
browser.form['UserName'] = UserName
^~~~~~~~~~
prog.cpp:47:3: error: invalid preprocessing directive #print
# print("login response %s "%(browser.response().read()))
^~~~~
prog.cpp:49:3: error: invalid preprocessing directive #for
# for form in browser.forms():
^~~
prog.cpp:50:7: error: invalid preprocessing directive #print
# print "Form name:", form.name
^~~~~
prog.cpp:51:7: error: invalid preprocessing directive #print
# print form
^~~~~
prog.cpp:53:26: warning: character constant too long for its type
newOutput = browser.open('https://www.justlogin.com/framegrabber.asp?body=/eleave/default.asp?rnd=178038120269322460430860711135637759&companyID=esko-india&userGuid=8A5F4C6F90B6447EA3190679323F1DBB')
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp:55:3: error: invalid preprocessing directive #Get
# Get response
^~~
prog.cpp:56:2: error: invalid preprocessing directive #suserPage
#suserPage = BeautifulSoup(response, 'html.parser')
^~~~~~~~~
prog.cpp:57:2: error: invalid preprocessing directive #print
#print("mechanize output %s"%(response.get_data()))
^~~~~
prog.cpp:2:1: error: ‘from’ does not name a type
from bs4 import BeautifulSoup
^~~~
Standard output is empty