0
我有這個小funnction:蟒蛇http.request autentification cookie的網頁登錄
def wp_login_check(url,username,password):
UA = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0"
headers = { 'User-Agent': UA, 'Content-type': 'application/x-www-form-urlencoded', 'Cookie': 'wordpress_test_cookie=WP+Cookie+check' }
http = httplib2.Http(timeout=10, disable_ssl_certificate_validation=True)
http.follow_redirects = True
body = { 'log':username,'pwd':password,'wp-submit':'Login','testcookie':'1' }
response, content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
url2 = url.replace('/wp-login.php','/wp-admin/plugin-install.php')
response1, content1 = http.request(url2)
print content1
我需要使用的第一個請求的cookie來第二次請求..怎麼能這樣?
不,不可能,需要使用http.request – kingcope 2014-12-19 11:59:07
@kingcope:無賴。 – mhawke 2014-12-19 12:00:47
@kingcope:httplib2的回答 – mhawke 2014-12-19 12:27:26