I found that the spaces in each line are divided by two encodings, although they look the same. Simply rewritten your code
# coding: utf-8
import re
import requests
from bs4 import BeautifulSoup
code = '000917电广传媒'
def getinfo(code,page):
baseurl = 'http://news.baidu.com/ns?word=title%3A%28{}%29&pn={}&cl=2&ct=0&tn=newstitle&rn=20&ie=utf-8&bt=0&et=0'.format(code,10*(page-1))
wd = requests.get(baseurl).content
soup = BeautifulSoup(wd,'lxml')
title = soup.select('.c-title > a ')
resource = soup.select('p .c-title-author')
resource1 = [i.text.encode('utf-8') for i in resource]
for i in resource1:
l = re.split("\xa02016|\xc2\xa0\xc2\xa0", i)
print l[0]
print l[1]
getinfo(code,1)
I found that the spaces in each line are divided by two encodings, although they look the same. Simply rewritten your code
The output result is
The timestamps in the data all start with a number, such as 59 minutes and 201 years. Why not try dividing by the first number.
It can be divided in python3 environment,