from lxml import etree
import requests
import os
import io
headers = {
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0"
}
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
resopnse = requests.get("http://www.shouce.ren",headers=headers)
text = resopnse.content
print(text)
html = etree.HTML(text)
detail_urls = html.xpath("//div[@class="thumbnail b-color-f"]//a/@href"<----
最后一行抛出异常
detail_urls = html.xpath("//div[@class="thumbnail b-color-f"]//a/@href")
^
SyntaxError: invalid syntax
[Finished in 0.2s with exit code 1]
但是我用火狐的try xpath做了过滤,确实没有问题,~~暂时找不到合适的理由来证明这个异常ennnnn