<jupyter_start><jupyter_text>zigbang 매물 데이터 저장- pip install geohash2<jupyter_code>!pip install pymongo
import warnings
warnings.filterwarnings('ignore')
import zigbang as zb
import pymongo
import pandas as pd
# server 연결
server = pymongo.MongoClient('mongodb://test:testpw@192.168.3.11:27017/')
db = server.zigbang
addrs = {
    "mongwon": "망원동",
    "hapjung": "합정동",
}
# 데이터 수집 후 저장
for collection_name, addr in addrs.items():
    collection = db[collection_name]
    datas = zb.oneroom(addr)
    ids = collection.insert(datas)
    print(collection_name, addr, len(ids))
# 망원동에서 월세 50이상 보증금 5000에서 10000조건으로 검색
QUERY = {"rent": {"$lte": 50}, "deposit": {"$lte": 10000, "$gte": 5000}}
results = db["mongwon"].find(QUERY)
df = pd.DataFrame(results).tail()
columns = ["title", "service_type", "sales_type", "deposit", "rent", "size_m2", "floor", "building_floor", "address1", "manage_cost", "is_new"]
df[columns]
# 컬렉션 삭제
for addr in addrs:
    print(addr)
    server.zigbang.drop_collection(addr)
# 데이터 베이스 삭제
server.drop_database("zigbang")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1568627450980392, 'fraction_numerical': 0.036414565826330535, 'mean_word_length': 5.536585365853658, 'pattern_counts': {'":': 7, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '138130', 'license': 'MIT', 'n_tokens_mistral': 492, 'n_tokens_neox': 495, 'n_words': 96, 'path': 'Summary/MongoDB/01_pymongo_zigbang.ipynb', 'repo_name': 'CATERINA-SEUL/MySQL', 'size': '1073'}