망원경으로 보는 구스타보
6008 단어 pythonopensource
세네카-CDOT / 망원경
Seneca의 오픈 소스 관련 궤도에 있는 블로그를 추적하는 도구
Telescope는 많은 기술을 사용하므로 Environment Setup Documentation의 모든 단계를 읽고 따라 시작하는 것이 가장 좋습니다.
이미 npm을 설치했기 때문에
brew를 사용하여 redis와 elasticsearch라는 두 가지 필수 기술을 설치했습니다.>>> brew install npm
>>> brew install redis
>>> brew tap elastic/tap
>>> brew install elastic/tap/elasticsearch-full
이제 세 개의 터미널 창을 열어 로컬 Telescope 서버를 실행할 수 있습니다.
>>> redis-server >>> elasticsearch >>> npm start 모든 것이 올바르게 작동하는 경우 http://localhost:3000/posts에 대한 브라우저를 열면 10개의 json 개체 배열이 표시되어야 합니다.
[{"id":"979c6d3eb5","url":"/posts/979c6d3eb5"},
{"id":"f1f56132fd","url":"/posts/f1f56132fd"},
{"id":"6413f59523","url":"/posts/6413f59523"},
{"id":"a0d10ce9e7","url":"/posts/a0d10ce9e7"},
{"id":"476491f37d","url":"/posts/476491f37d"},
{"id":"d5eed3b8ec","url":"/posts/d5eed3b8ec"},
{"id":"b1f2991c27","url":"/posts/b1f2991c27"},
{"id":"6fc08da083","url":"/posts/6fc08da083"},
{"id":"1aca420d0f","url":"/posts/1aca420d0f"},
{"id":"6ba1ae431a","url":"/posts/6ba1ae431a"}]
다음으로 위 URL의 HTTP 상태를 확인하기 위해 업데이트Gustavo를 원했습니다. Gustavo는 파일을 통해 HTTP://또는 HTTPS://로 시작하는 모든 문자열을 검색하고 일치하는 모든 목록을 생성하는 방식으로 작동합니다. 그런 다음 이 목록이 처리됩니다. 위의 json에서 완전한 형식의 URL 목록을 생성할 수 있다면 프로그램이 작동할 것임을 알았습니다.
추가 플래그
args.py 또는 -t를 처리하도록 --telescope를 업데이트했습니다.parser.add_argument('-f', '--file', action='store', dest='source', default='', help='location of source file')
parser.add_argument('-t', '--telescope', action='store_const', dest='source', const='TELESCOPE', help='check recent posts indexed by Telescope')
파일 경로를 지정하는 대신
-t 또는 --telescope 플래그를 사용하면 TELESCOPE 문자열을 소스 변수에 저장합니다. 프로그램은 get_list() 함수가 호출될 때까지 정상적으로 실행됩니다. 이때 소스 변수의 값이 TELESCOPE이면 다음 코드가 실행된다.posts = requests.get('http://localhost:3000/posts')
urls = re.findall('/posts/[a-zA-Z0-9]{10}', posts.text)
return ['http://localhost:3000' + url for url in urls]
무엇을합니까?
이제 터미널로 돌아가 명령을 실행합니다.
>>> python gus.py -t
다음 출력을 생성합니다.
[GOOD] [200] http://localhost:3000/posts/78e5ab8438
[GOOD] [200] http://localhost:3000/posts/2da60bf766
[GOOD] [200] http://localhost:3000/posts/4a8a76df4a
[GOOD] [200] http://localhost:3000/posts/e5f703c004
[GOOD] [200] http://localhost:3000/posts/168346fd63
[GOOD] [200] http://localhost:3000/posts/db7e046128
[GOOD] [200] http://localhost:3000/posts/f87957048e
[GOOD] [200] http://localhost:3000/posts/35b33ca432
[GOOD] [200] http://localhost:3000/posts/3555e6f683
[GOOD] [200] http://localhost:3000/posts/868b94d523
변경 사항에 대한 전체 요약은 아래에서 볼 수 있습니다.
Reference
이 문제에 관하여(망원경으로 보는 구스타보), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/slaterslater/gustavo-looks-through-a-telescope-27gc텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)