python requests freeze program

alsaibi :

I tried to use request to get status code from a web page but there is no output and the program stop at the request.get

my code

if requests.get("https://storage.googleapis.com/linear-theater-254209.appspot.com/v5.4animu.me/Hunter-x-Hunter/Hunter-x-Hunter-Episode-1-1080p.mp4").status_code == 200:
  print("link is working")
else:
  print("link is not working")

the code worked on another machine

I think it's downloading the video but I just want the status code

I didn't download files using requests before so IDK about that

Edit: it also works on Collaboratory https://colab.research.google.com/drive/1yECaNKQNsyDUuGhBfcEa2OhDUUqqeg_q

alefmim :

You can use requests.head() to get the headers like this :

    import requests

    if requests.head("https://storage.googleapis.com/linear-theater-254209.appspot.com/v5.4animu.me/Hunter-x-Hunter/Hunter-x-Hunter-Episode-1-1080p.mp4").status_code == 200:
      print("link is working")
    else:
      print("link is not working")

requests.get() will download the requested URL and since the file you requested here is not small it may take some time. if you want to check the headers and status code it's better to use requests.head() instead.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=398492&siteId=1