[Python] 学习urllib库

from urllib import request
from urllib import parse
from selenium import webdriver

url1 = 'http://www.baidu.com'

# 使用urlopen请求网页
re = request.urlopen(url1)
# print(re.read())
print(re.getcode())

# 使用urlretrieve下载网页
# request.urlretrieve(url1, 'baidu.html')

# webdriver驱动网页
# wd = webdriver.Chrome()
# wd.get(url1)

# 使用parse编解url码
data = {'张三': '你好', '李四': '不好', '王五': '真好', '大家': '打架'}
data_encode = parse.urlencode(data)
print(data_encode)
data_decode = parse.parse_qs(data_encode)
print(data_decode)

猜你喜欢

转载自www.cnblogs.com/sakur/p/10322900.html
今日推荐