Giter VIP home page Giter VIP logo

Comments (6)

kw-lee avatar kw-lee commented on August 14, 2024 5

이 패키지를 사용해서 알프레드 워크플로우를 만들어 배포했었었는데 임시 조치로 passportKey 발급받아 사용하는 것으로 해결했습니다. (완벽한 해결책은 아닙니다)

그때그때 토큰을 받아오는 것은 네이버에 너무 자주 요청을 보내게 되어 토큰을 저장해 사용하였습니다.
구체적으로는 다음과 같은 방식을 택했습니다.

  1. passportKey가 주어지면 해당 값 사용
  2. passportKey가 없고 token.txt에 값이 있으면 사용
  3. 문제가 생기면 새로 passportKey를 발급받아 token.txt 에 저장하고 사용
def read_token():
    with open("token.txt", "r") as f:
        TOKEN = f.read()
    return TOKEN

def update_token(agent):
    """update passportkey
    from https://gist.github.com/AcrylicShrimp/4c94db38b7d2c4dd2e832a7d53654e42
    """

    html = agent.get(url='https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=1&ie=utf8&query=맞춤법검사기') 

    match = re.search('passportKey=([a-zA-Z0-9]+)', html.text)
    if match is not None:
        TOKEN = parse.unquote(match.group(1))
        with open("token.txt", "w") as f:
            f.write(TOKEN)
    return TOKEN

전체 커밋은 kw-lee/alfhanspell@5826618 에서 확인하실 수 있습니다.

민감한 정보가 아니라 로컬에 저장해도 문제가 없어 임시로 텍스트파일에 저장하는 식으로 구현하였는데, 패키지에서 구현하려면 임시 파일(tmpfile)이나 쿠키를 사용해서 토큰을 저장 및 불러오는 방식을 고려해보시면 어떨까합니다.

from py-hanspell.

ssut avatar ssut commented on August 14, 2024

조만간 fix 올리겠습니다.

from py-hanspell.

Mr-taek avatar Mr-taek commented on August 14, 2024

오류가 떠서 이유를 찾다보니.. base_url 변수의 주소에서 "유효한 키값이 아닙니다"라고 return하는 것같아요

from py-hanspell.

soulduse avatar soulduse commented on August 14, 2024

@Mr-taek 넵 맞습니다. 새로운 파라미터(passportKey)가 추가 되었는데 이 값이 없으면 동작하지 않습니다.

from py-hanspell.

soulduse avatar soulduse commented on August 14, 2024

현재 며칠 살펴보니 하루에 한번 바뀌는것 같아요 아마도 자정이 넘어가는때 쯤인것 같습니다.

from py-hanspell.

soulduse avatar soulduse commented on August 14, 2024

@kw-lee 괜찮은 아이디어 인것 같네요!

from py-hanspell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.