Python爬虫学习(单线程爬虫(一))

import requests
import re
import sys
reload(sys)
sys.setdefaultencoding("gb18030")
type = sys.getfilesystemencoding()
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 UBrowser/5.5.10106.5 Safari/537.36'}
html = requests.get('http://jp.tingroom.com/yuedu/yd300p/',headers = headers)
html.encoding = 'utf-8'
#print html.text
# Japanese = re.findall('color:#666666;">(.*?)',html.text,re.S)
# for each in Japanese:
#     print each
chinese = re.findall('color: #039;">(.*?)',html.text,re.S)
for each in chinese:
    print each

你可能感兴趣的:(Python学习)