Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requests.exceptions.TooManyRedirects: Exceeded 30 redirects #10

Open
diligejy opened this issue Mar 2, 2020 · 0 comments
Open

requests.exceptions.TooManyRedirects: Exceeded 30 redirects #10

diligejy opened this issue Mar 2, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@diligejy
Copy link
Contributor

diligejy commented Mar 2, 2020

다음과 같이 header값을 입력하고 session의 max_redirect를 늘려보았습니다.
이렇게 하면 대한민국 업데이트 완료까지는 가능하지만,
국내 업데이트에서 막힙니다.

헤더 문제나 다른 문제가 아니라,
이 부분에서 에러가 있지 않을까 싶습니다.

  def scrape_KCDC_citydo():
 """질병관리본부의 시도별 발생동향 수집"""
 request_headers = {
             'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
              'Accept-Encoding' : 'gzip, deflate',
              'Accept-Language' : 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7',
              'Cache-Control' : 'max-age=0',                                                                                                                                                             
               'Connection' : 'keep-alive',                                                                                                                                                               
               'Cookie' : '_ga=GA1.3.902460717.1582188059; _gid=GA1.3.1299466237.1583138633; JSESSIONID=hUEn1QgHlDMNI2gSSZJxuN0zYGahJogaUyaeAEvgyXstvqyq4C13pOf4dNGoOdid.mohwwas1_servle    t_engine40; NetFunnel_ID=; _gat_gtag_UA_26269343_2=1',
               'Host' : 'ncov.mohw.go.kr',                                                                                                                                                                
               'Referer' : 'http://ncov.mohw.go.kr/bdBoardList_Real.do?brdId=1&brdGubun=13&ncvContSeq=&contSeq=&board_id=&gubun=&fbclid=IwAR3NoNL_j1phitehSggDQedf7S165308xIEeG8ljACy-VR    q-T5efcbcTK_s',                                                                                                                                                                                             
                  'Upgrade-Insecure-Requests': '1',
                 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36',
              }                                                                                                                                                                                             
session = requests.Session()                                                                                                                                                               
session.max_redirects = 6000000                                                                                                                                                              
html = session.get("http://ncov.mohw.go.kr/bdBoardList_Real.do?brdId=1&brdGubun=13&ncvContSeq=&contSeq=&board_id=&gubun=&fbclid=IwAR3NoNL_j1phitehSggDQedf7S165308xIEeG8ljACy-VRq-T5e    fcbcTK_s", headers = request_headers)   

image

@taeukkang taeukkang added the bug Something isn't working label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants