爬取网站为:https://jn.58.com/chuzu/?PGTID=0d100000-0010-997a-6ba0-3b2a61df3202&ClickID=2
import requests
from lxml import etree
url = 'https://jn.58.com/chuzu/?PGTID=0d100000-0010-997a-6ba0-3b2a61df3202&ClickID=2'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
}
response = requests.get(url=url, headers=headers)
# print(response.text)
html = etree.HTML(response.text) # 将结果存储到html中
data_title = html.xpath('//div[@class="des"]/h2/a/text()') # 标题
data_money = html.xpath('//div[@class="money"]/b/text()') # 价钱
for data_t in data_title: # 标题
print(str(data_t).strip())
运行结果: