1.JS 三元表达式
前置条件 ? 结果一 : 结果二;
不管写成什么格式,都按照这样去看
2.xpath小语法
res= requests.get('url').text html = etree.HTML(res) # 取出包含文章主体 content= html.xpath('//*body[@id="aaa"]')[0] text_one= etree.tostring(content, method='html') text_two= HTMLParser().unescape(text_one.decode()) print(text_two)
text= response.xpath('//*span[@class="newText"]').xpath('string(.)')[0]
3.pyexecjs
import execjs with open('tj.js','r',encoding='utf-8') as f: f_js = f.read() f_js = execjs.compile(f_js.encode.decode('gbk','ignore')) link_name = f_js.call('get_PWD','123456')