python requests响应得到的是element , 求大神解答 !!!!!!!!!!!!!!!!!!!!!!

import requests
from lxml import etree
url = 'https://www.aqistudy.cn/historydata/monthdata.php?city=枣庄'

'''headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Cookie': 'UM_distinctid=170c947ef262f1-0ef5363c26de6a-34564a7c-100200-170c947ef2787; CNZZDATA1254317176=170373159-1583923213-%7C1584096035',
'Host': 'www.aqistudy.cn',
'Referer': 'https://www.aqistudy.cn/historydata/monthdata.php?city=%E9%93%B6%E5%B7%9D',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3741.400 QQBrowser/10.5.3863.400'
}'''
r = requests.get(url)
print(r)
html = etree.HTML(r.text)
print(html)
#day_url_list = html.xpath('/html/body/div[3]/div[1]/div[1]/table/tbody/tr/td/a/@href')
#for a in day_url_list:
#print(a)
#print(r.text)图片说明

1个回答

r = requests.get(url)
htmlstr = r.content.decode()
print(htmlstr)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问