Skip to content

Instantly share code, notes, and snippets.

@wangx2
Created April 22, 2016 12:17
Show Gist options
  • Save wangx2/beadd4649466df2fef2078e99e804249 to your computer and use it in GitHub Desktop.
Save wangx2/beadd4649466df2fef2078e99e804249 to your computer and use it in GitHub Desktop.
#! /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