解决了IDE中文显示的问题,通过print(soup.head.title).encode('gb18030')解决了中文路径无法打开的问题。
通过file=open(u"D:/users/nancy/share/sae6depart/6系资料/python/crawl.txt","w")。
import urllib
from urllib import urlopen
c=urllib.urlopen("http://www.baidu.com")
contents=c.read()
print(contents[0:50])
from bs4 import BeautifulSoup
soup=BeautifulSoup(urlopen("http://www.baidu.com"))
print(soup.head.title).encode('gb18030')
file=open(u"D:/users/nancy/share/sae6depart/6系资料/python/crawl.txt","w")
好了现在开始正式的========================================================