Created
April 22, 2016 12:17
-
-
Save wangx2/beadd4649466df2fef2078e99e804249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# coding:utf-8 | |
import urllib.request | |
import re | |
import http.cookiejar | |
url = 'http://www.lvye.org/user.php' | |
user_url = 'http://www.lvye.org/modules/news/article.php?storyid=20' | |
user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' | |
referer = 'http://www.lvye.org/' | |
value = { | |
'uname':'ceshipachong', | |
'pass':'281346230', | |
'op':'login' | |
} | |
header = {'User_Agent':user_agent} | |
data = urllib.parse.urlencode(value).encode(encoding='utf_8') | |
"""request = urllib.request.Request(url,data ,header) | |
response = urllib.request.urlopen(request) | |
print(response.read().decode('utf-8'))""" | |
#url_ok = re.findall(r'http://.*\d',ok) | |
cj = http.cookiejar.CookieJar() | |
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj)) | |
request = urllib.request.Request(url,data,header) | |
login = opener.open(request) | |
aa = opener.open(user_url) | |
print(aa.read().decode('utf-8')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment