Skip to content

Commit

Permalink
Merge pull request #15 from Banryeo/distributeTest
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
acisliver authored Jun 18, 2021
2 parents 1839a4d + e3228a7 commit 88d034d
Show file tree
Hide file tree
Showing 50 changed files with 19,171 additions and 13 deletions.
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/test/**/build/
.idea/workspace.xml

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
/frontend/node_modules/
17 changes: 17 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

199 changes: 199 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Crawling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### 1. 제주시 API 관련
API가 데이터를 한 번에 10개씩 받아오기에 저장되는 json **파일은 하나지만, 그 안의 내용은 여러개의 json 파일이 합쳐진 모양입니다.**
정상적인 json 형식은 []가 하나만 있어야 합니다. 소스코드대로 저장하면 ' [1번째 받은 데이터][2번째 받은 데이터][...][마지막으로 받은 데이터] ' 모양이 됩니다.
텍스트 편집기로 " ][ "를 " , "로 대치하는 걸로 해결했습니다.

### 2. 서귀포시 API 관련
서귀포시 API는 현재 달의 달력을 제공하고, 그 달력의 모든 행사를 요일별로 제공합니다.
중복되는 데이터를 DB 내에서 중복을 제거하는 방식으로 해결했습니다.
58 changes: 58 additions & 0 deletions Crawling/api_jejusi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


from urllib.request import urlopen
from urllib.parse import urlencode, unquote, quote_plus
import requests
import json
import xmltodict

fileName = 'jejusi.json'
file = open(fileName, 'w', encoding='utf-8')

// https://www.data.go.kr/data/15002244/openapi.do
apiUrl = '### api url ###'

names_key = { 'edate': 'endDate',
'sdate': 'startDate',
'info': 'explanation',
'title': 'cultureName' }

def getJson(url):
get_data = requests.get(url)
xpars = xmltodict.parse(get_data.text)
jsonDump = json.dumps(xpars)
jsonBody = json.loads(jsonDump)
return jsonBody

def rename(Body):
final = Body['rfcOpenApi']['body']['data']['list']
for row in final:
for k, v in names_key.items():
for old_name in row:
if k == old_name:
row[v] = row.pop(old_name)
return final

def save(data):
json.dump(data, file, indent=4, ensure_ascii=False)


for i in range(0, 61):
queryString = "?" + urlencode({
"ServiceKey" : unquote("### your key ###"),
"pageNo" : i,
"numOfRows" : 10
})

body = getJson(apiUrl+queryString)
result = rename(body)
save(result)

file.close()



Loading

0 comments on commit 88d034d

Please sign in to comment.