赞
踩
需要安装Python3环境及第三方库,此处以linux为例:
第三方库 requests pymongo和mongodb数据库
以合肥某区域房价为例:https://hf.lianjia.com/ershoufang/jingkai2/l3a3/
#!/usr/bin/env python3 import requests import os,sys,time import pymongo from bs4 import BeautifulSoup header={ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.104' } start=0 def main(): for i in range(1,20): url="https://hf.lianjia.com/ershoufang/jingkai2/l3a3/"+'pg'+str(i) #print(url) html=requests.get(url=url,headers=header) html.encoding=
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。