title: Downloading file from URL using Python - Unknown error
body: <p>I am having a problem downloading a file from a specific Korean URL. When I googled how to download files through URL, it recommended many solutions such as using urlretrieve, urlopen, wget. However, whenever I try, it saves a 0 byte PDF file and it does not return any error message.</p>
  <p>So I tired using other program such as Postman or J2downloader and they saved <code>pdf.do</code> with 0 byte. I know <code>.do</code> could be opened with Acrobat Reader but the size tells me that it was not able to download the contents.</p>
  <p>The URL of the site is <a href="http://dart.fss.or.kr/pdf/download/pdf.do?rcp_no=20210218000576&amp;dcm_no=7808922" rel="nofollow noreferrer">http://dart.fss.or.kr/pdf/download/pdf.do?rcp_no=20210218000576&amp;dcm_no=7808922</a>. If I open it through a website, it downloads correctly.</p>
  <p>Now I am not sure whether it's my code problem or the site mechanism is different. If it's the websites mechanism, could you tell me how to make it work on using Python?</p>
  <p><strong>Code that I tried</strong></p>
  <pre class="lang-py prettyprint-override"><code>final_url = http://dart.fss.or.kr/pdf/download/pdf.do?rcp_no=20210218000576&amp;dcm_no=7808922
  1. 
      urlretrieve(final_url, &quot;./down2.pdf&quot;)
  2.
      with open(&quot;down.pdf&quot;,'wb') as file:
          response = requests.get(final_url, allow_redirects=True)
          print(response.content)
          file.write(response.content)
  3. 
      mem = urlopen(final_url).read()
      with open(&quot;down.pdf&quot;,'wb') as file:
          file.write(mem)
          file.close()
  4.
      wget.download(final_url, &quot;my download folder&quot;)
  </code></pre>