Exemple #1
0
 def get_tax_office_name(self):
     road_name = self.road_name
     url = "https://www.nts.go.kr/wtsuser/about_semuFind.asp"
     params = {
         "search_type": "R",
         "keyword": road_name.encode("euc-kr"),
         "target": "search_semu"
     }
     res = requests_get(url, params=params)
     soup = BeautifulSoup(res.content.decode("euc-kr"), features="lxml")
     tax_office_name = self.select_one_tax_office_name(soup)
     return tax_office_name
Exemple #2
0
 def _juso_res_json(self):
     # TODO: api 콜은 여기가 아니라 따로 caller 로 빼기
     url = "http://www.juso.go.kr/addrlink/addrLinkApi.do?"
     splited_address = self.address.split()
     # 미리 세팅한 이유는 4개 미만인경우 dict 를 만들어서 넘겨줘야 하기때문
     # 도로명주소, 지번주소, 우편번호, 도로명(도로이름)
     result = {
         "results": {
             "juso": [{
                 "roadAddr": self.address,
                 "jibunAddr": self.address,
                 "zipNo": None,
                 "rn": None
             }]
         }
     }
     params = {
         "resultType": "json",
         "confmKey": settings.ADDERSS_SEARCH_API_KEY
     }
     if len(splited_address) < 4:
         if (not splited_address[-1].endswith("동")) or (
                 1 <= len(splited_address) < 3):
             return result
         # TODO: 리팩토링
         params["keyword"] = self.address
         res = requests_get(url, params=params)
         result = json_loads(res.text)
     else:
         for token_count in range(4, len(splited_address) + 1):
             # TODO: 리팩토링
             params["keyword"] = " ".join(splited_address[:token_count])
             res = requests_get(url, params=params)
             json_res = json_loads(res.text)
             if json_res["results"]["juso"]:
                 result = json_res
             else:
                 break
     # TODO: 3어절로 검색하면 주렁주렁 붙는데 이에대한처리 추가
     return result
Exemple #3
0
 def test_requests_get(self):
     res = requests_get("http://student.wink.co.kr/health.txt")
     assert res.status_code == 200
     assert res.content == b"OK"
     assert res.text == "OK"