xml_con = '''
({"domid":"bpmodule-main","js":[],"css":[],"html":"\n\n\n \n\n\t\n\t<div data-spm=\"filter\" class=\"arrow-up mod-filter \">\n\t\t<dl>\n\t\t\t<dt>日期:</dt>\n\n\t\t\t<dd>\n<a data-spm=\"dpubtime\" data-filter=\"{"limit_date":"0"}\" class=\
'''
ykurl = 'https://so.youku.com/search_video/q_%E5%9C%A8%E8%BF%9C%E6%96%B9'
cookies = '__ysuid=1571499703623SrM; _m_h5_tk=bfcae7e1b08cea971f4bee6d0d905350_1572247978748; _m_h5_tk_enc=e414e24ae0b0e4be9d154cb850678516; P_ck_ctl=33BB1EF3E40D4A78F5803421095CD4C1; UM_distinctid=16e0dc06837b9-0a4d3e130cbe148-4c312d7d-13c680-16e0dc068381aa; cna=AWp5FR4/iGACATo+tdY8N+ks; __ayft=1572188745156; __aysid=1572188745156o9c; __arpvid=15721901367247U83yd-1572190136780; __ayscnt=1; __aypstp=5; __ayspstp=5; isg=BKysOcrE3cmPncn2BJaxRZG2fooezZfu_E69EAbtuNf6EUwbLnUgn6KgMRkMgohn'
#cookies = requests.utils.dict_from_cookiejar(cookies)
def extract_cookies(cookie):
cookies = dict([l.split("=", 1) for l in cookie.split("; ")])
return cookies
cookies = extract_cookies(cookies)
rehtml= html_geturl(ykurl,cookies=cookies)
poshtml= strsub(rehtml,'bigview.view','\"page-nav','ng') # def str sub function
aa = html.unescape(poshtml) # request html ,Intercept html section
bb = html.unescape(xml_con) #this is var xml_con
print(type(aa)) #class str
print(type(bb)) #class str
print(aa)
print(bb)
由于str太长,因此我在此处删除了一些内容。如果我将结果设置为变量,则html_unescape将会生效,而请求的结果也不会生效。这是为什么,如果您理解,请帮助我,谢谢