import requests
from bs4
import BeautifulSoup
import re
from lxml
import etree
import time
if __name__
== "__main__":
headers
= {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36'
}
url
= 'https://bz.58.com/ershoufang/?utm_source=market&spm=u-2d2yxv86y3v43nkddh1.BDPCPZ_BT&PGTID=0d100000-003b-0e56-85b3-c5c32ec9116c&ClickID=4'
page_text
= requests
.get
(url
=url
, headers
=headers
).text
tree
= etree
.HTML
(page_text
)
li_list
= tree
.xpath
('//ul[@class="house-list-wrap"]/li')
fp
= open('58.txt', 'w', encoding
='utf-8')
for li
in li_list
:
title
= li
.xpath
('./div[2]/h2/a/text()')[0]
print(title
)
fp
.write
(title
+'\n')
转载请注明原文地址:https://tech.qufami.com/read-3002.html