需要安装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