python programm to log into the web page -


Does anyone know what's wrong with this code? When I run it, I get back to the same HTML page. I # - * - Coding: UTF-8 - * - http Import Cookies Import URLB.Request Import from urllib.parse to bs4 Import Sundersup login = "username" password = "password" cookie = cookiejar.CookieJar () urlOpener = \ urllib.request.build_opener (urllib.request.HTTPCookieProcessor (cookiejar)) urlOpener.addheaders = [( 'user-agent' 'Mozilla / 5.0 (X11 Linux i686) AppleWebKit / 537.36 (KHTML,' { ': entry,' User_pass' Password 'Login' 'connected' user_name} data = urllib.parse.urlencode (value) binary_data = data Pic) Chrome / 37.0.2062.120 Safari / 537.36)] value = '.encode (' utf-8 ') request = urllib.request.reequest (' http://securityoverride.com/login.php ', binary_data) URL1 = urlOpener.open (request) url2 = urlOpener.open ( 'http: //securityoverride.org/challenges/programmin/1/index.php') soup = beautiful soup (url2.read (), 'lxml') print Soup.fund_all ('center')

  urlib.request import import urllib Import from http import Cookiejar to bs4 BeautifulSoup url = "http://securityoverride.com/login.php" name = "username" passw = "password" def login (): cj = cookiejar.CookieJar () user_agent = 'Mozilla / 4.0 (compatible; MSIE 5.5; Windows NT) 'headers = {' user-agent ': USER_AGENT} redirect = urllib.request.HTTPRedirectHandler () Opener = urllib.request.build_opener (urllib.request.HTTPCookieProcessor (CJ)) value = {' USER_NAME ': Access , 'User_pass' Password 'Login' 'log'} data = urllib.parse.urlencode (value) binary_data = data.encode ( 'utf-8') English = urllib.request.Request (URL, binary_data, headers ) Login_response = Openerkopen (Log) url2 = urlOpener.open ( 'http://securityoverride.org/challenges/programmin/1/index.php') soup = print BeautifulSoup (url2.read (), 'lxml') Soup .find_all ('center') Login ()    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -