fork download
  1. # -*- coding: utf-8 -*-
  2. from bs4 import BeautifulSoup
  3. import requests
  4. import mechanize
  5. import mechanicalsoup
  6. import http.cookiejar
  7. import html2text
  8. from mechanize import Browser
  9.  
  10. browser = Browser()
  11.  
  12.  
  13.  
  14. #Create a browser object
  15. URL = 'https://w...content-available-to-author-only...n.com/login.aspx'
  16. CompanyName = "esko-india"# email login
  17. password = "Tukudude16@#"
  18. UserName = "ekma" # without @
  19. browser = mechanize.Browser()
  20. browser.set_handle_robots(False) # no robots
  21. browser.addheaders = [('User-agent', 'Chrome')]
  22.  
  23. response = browser.open(URL)
  24. print response.read()
  25.  
  26. for form in browser.forms():
  27. print "Form name:", form.name
  28. print form
  29.  
  30. # print browser.form.control
  31. # for control in browser.form.control:
  32. # print control
  33. # print "type=%s, name=%s value=%s" % (control.type, control.name, browser[control.name])
  34. # browser.select_form('form1')
  35. #response = browser.openurl('https://w...content-available-to-author-only...n.com/eleave/phistory.ASP?WhatRole=NONE&rnd=941137528418219221776723987672889231')
  36. #print("response data %s"%(response))
  37.  
  38.  
  39. # Select the form
  40. browser.select_form(nr=0)
  41. browser['CompanyName'] = CompanyName
  42. browser.form['password'] = password
  43. browser.form['UserName'] = UserName
  44. response = browser.submit()
  45. print("login info %s "%(response.info()))
  46.  
  47. # print("login response %s "%(browser.response().read()))
  48.  
  49. # for form in browser.forms():
  50. # print "Form name:", form.name
  51. # print form
  52.  
  53. 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')
  54. print("second page data %s "%(browser.response().read()))
  55. # Get response
  56. #suserPage = BeautifulSoup(response, 'html.parser')
  57. #print("mechanize output %s"%(response.get_data()))
  58.  
  59.  
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
 ^~~~
stdout
Standard output is empty