url = 'https://cn.58.com/ershoufang/?PGTID=0d100000-008d-2b3d-c8f5-0c7b463b18e3'
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.47'
resp = requests.get(url=url, headers=headers)
encoding = chardet.detect(resp.content)['encoding']
tree = etree.HTML(page_text)
h3_list = tree.xpath('//div[@class="property-content-title"]/h3[@class="property-content-title-name"]/text()')
price_list = tree.xpath('//div[@class="property-price"]//span[@class="property-price-total-num"]/text()')
for i in range(min(len(h3_list), len(price_list))):
h3_price.append((h3_list[i], price_list[i] + "w"))
with open('D:\\Programming\\Microsoft VS Code Data\\WebCrawler\\data\\58\\58.txt', 'w', encoding=encoding) as fp:
fp.write(f'{item[0]} {item[1]}\n')
