37,720
社区成员
发帖
与我相关
我的任务
分享
# -*- coding:utf-8 -*-
##从新浪网爬取新闻
import requests
from bs4 import BeautifulSoup
newsurl='http://news.sina.com.cn/china/'
# newsurl='http://www.city-data.com/city/Honolulu-Hawaii.html' #这个为啥不行,结果是乱码的
res = requests.get(newsurl)
res.encoding = 'utf-8'
soup = BeautifulSoup(res.text,'html5lib')
print(res.text)