代码拉取完成,页面将自动刷新
import logging
from community import GetCommunityName
from house_info import GetInfo
from concurrent.futures import ThreadPoolExecutor
# 设置日志格式
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
# 设置时间格式
DATE_FORMAT = "%m/%d/%Y %H:%M:%S %p"
logging.basicConfig(filename='test.log', level=logging.INFO, format=LOG_FORMAT, datefmt=DATE_FORMAT)
def get_info(community_name):
info = GetInfo(community_name)
# 获取挂牌房源id
gpfyids = info.get_gpfyid()
# 通过挂牌房源id获取房源详情信息并存入数据库
if gpfyids:
logging.info("获取小区<%s>成功" % community_name)
for gpfyid in gpfyids:
info.get_detail_content(gpfyid)
info.get_image_content(gpfyid)
else:
logging.info("获取小区<%s>未成功" % community_name)
def main():
# 获取小区名称
app = GetCommunityName()
community_name_list_generator = app.run()
# 多线程获取小区某二手房挂牌信息
for community_name_list in community_name_list_generator:
with ThreadPoolExecutor(len(community_name_list)) as executor:
executor.map(get_info, community_name_list)
if __name__ == "__main__":
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。