html = etree.HTML(response.text) html_code = html.xpath("//div[@class='content clearfix']")[0] html_code = etree.tostring(html_code, encoding="utf8").decode('utf-8')#将编码文本化查看
response = requests.get(url=url,headers=header,timeout=30) html = etree.HTML(response.text) html_code = html.xpath("//td[@align='right']/a") html_page_code = html_code[0].attrib['href']
.attrib['href']获取链接信息
enumerate 获取for循环当前循环次数
示例如下: