|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#! /usr/bin/env python3
import urllib.parse
import urllib.request
url = 'http://192.168.240.128/wp/wp-login.php'
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
values = {
'log' : 'xxx',
'pwd' : '123456'
}
data = urllib.parse.urlencode(values)
req = urllib.request.Request(url, data)
req.add_header('Referer', 'http://192.168.240.128/')
response = urllib.request.urlopen(req) ----> 为什么到这一步的时候老是报错呢:报错如下 :
the_page = response.read()
print(the_page.decode("utf8"))
报错:
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
response = urllib.request.urlopen(req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\urllib\request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\urllib\request.py", line 463, in open
req = meth(req)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\urllib\request.py", line 1170, in do_request_
raise TypeError(msg)
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str. |
|