import requests
from lxml import html
import time
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4094.1 Safari/537.36"}
url = "http://finance.jrj.com.cn/2018/01/01200423879416.shtml"
try:
rep = requests.get(url, headers = headers, timeout = 5)
time.sleep(1)
if rep.status_code == 200:
print("")
con = rep.content
sel = html.fromstring(con)
date = sel.xpath("//div[@class="texttit_m1"]/p/text()")
date = str(date).replace("]", "").replace("[", "").replace(""", "").replace(u"\u3000", "")
print(date)
except Exception as e:
print("::" +url + " , ::", e)
pass
cannot delete the u3000 replace before climbing down text