-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpractice.py
More file actions
28 lines (24 loc) · 1 KB
/
practice.py
File metadata and controls
28 lines (24 loc) · 1 KB
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
import requests, bs4
import pandas as pd
from lxml import html
from urllib.request import Request, urlopen
from urllib.parse import urlencode, quote_plus, unquote
API_key = unquote("71wIrgVtoA73X2mMZ5VzxKcPT7cUGUdUle%2Be0w%2BwmCc5AO%2F6Oion4qdMPIKWLRlfJFzymt8YCoDf%2FAtpMoSMwA%3D%3D")
URL = "http://apis.data.go.kr/B551011/KorService1/searchKeyword1?"
queryParams = '?' + urlencode(
{
quote_plus('ServiceKey'): API_key,
quote_plus('MobileOS'): 'WIN',
quote_plus('MobileApp'): 'AppTest',
quote_plus('arrange'): 'A',
quote_plus('keyword'): '스파',
}
)
response = requests.get(URL + queryParams).text.encode('utf-8')
xmlobj = bs4.BeautifulSoup(response, 'lxml-xml')
rows = xmlobj.findAll('item')
print(rows)
# numOfRows=12&pageNo=1&MobileOS=ETC&MobileApp=AppTest&ServiceKey={API}&listYN=Y&arrange=A&areaCode=&sigunguCode=&cat1=&cat2=&cat3=&keyword=스파&_type=json".format(API = API_key)
# response = urlopen(URL)
# json_api = response.read().decode("utf-8")
# print(json_api)