일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- kolla-ansible
- HTML
- ceph-ansible
- awx
- OpenStack
- nfs-provisioner
- ubuntu
- Kubeflow
- kolla
- pacman
- archlinux
- Docker
- port open
- ceph
- grafana-loki
- Linux
- yum
- repository
- Arch
- Octavia
- Ansible
- Kubernetes
- terraform
- golang
- cloud-init
- KVM
- k8s
- libvirt
- i3
- cephadm
Archives
- Today
- Total
YJWANG
[Python] 부동산 크롤러-2 본문
크롤러-1 에서 가져온 dict를 flask_table을 이용해 html table로 변형하는 코드이다.
import requests, json
from flask_table import Table, Col
class ItemTable(Table):
classes = ['table', 'table-striped', 'table-bordered', 'table-condensed']
articleName = Col('단지')
buildingName = Col('동')
tradeTypeName = Col('매물 종류')
dealOrWarrantPrc = Col('금액')
floorInfo = Col('층')
area2 = Col('평수')
articleConfirmYmd = Col('매물 일자')
articleFeatureDesc = Col('설명')
tagList = Col('태그')
cpPcArticleUrl = Col('링크')
#representativeImgUrl = Col('이미지 링크')
# header 담아서 url에 get 요청 진행 후
# json을 dict 형태로 변환해서 저장
url = 'https://new.land.naver.com/api/articles/complex/2588?realEstateType=APT%3AABYG%3AJGC&tradeType=B1&tag=%3A%3A%3A%3A%3A%3A%3A%3A&rentPriceMin=0&rentPriceMax=900000000&priceMin=0&priceMax=33000&areaMin=0&areaMax=900000000&oldBuildYears&recentlyBuildYears&minHouseHoldCount&maxHouseHoldCount&showArticle=false&sameAddressGroup=true&minMaintenanceCost&maxMaintenanceCost&priceType=RETAIL&directions=&page=1&complexNo=2588&buildingNos=&areaNos=&type=list&order=rank'
headers = {'User-Agent' : 'yjwang'}
resp = requests.get(url, headers = headers).json()
try:
table = ItemTable(resp['articleList'])
except:
pass
print(table.__html__())
# html 결과를 아래와 같이 파일로 저장
f = open('./test.html', 'w')
f.write(table.__html__())
f.close()
반응형