Why does’t !wget -P use the full link?

  python, wget

I am using this code on google colab to save media files from a number of links stored in a text file:

url_file = open('myfile.txt','r')
for url in url_file.readlines():
   !wget -P /content/drive/MyDrive/gadgets Drive/dirUrl {url}
   # Testing if the url is printed correctly
   print (url)
url_file.close()

if I give it short links (ex: https://bugs.python.org/file47781/Tutorial_EDIT.pdf) it saves it to my google drive with no problem. However, if the link is of a picture from social media it gives the following error:

https://scontent-nrt1-1.cdninstagram.com/v/t51.2885-15/sh0.08/e35/p640x640/126516826_127286402286618_3888059563713165418_n.jpg?_nc_ht=scontent-nrt1-1.cdninstagram.com
Resolving scontent-nrt1-1.cdninstagram.com (scontent-nrt1-1.cdninstagram.com)… 31.13.82.52, 2a03:2880:f20f:c4:face:b00c:0:43fe
Connecting to scontent-nrt1-1.cdninstagram.com (scontent-nrt1-1.cdninstagram.com)|31.13.82.52|:443… connected.
HTTP request sent, awaiting response… 403 Forbidden

What it does is that it takes only part of the link given above and discards the rest which is:

&_nc_cat=1&_nc_ohc=DhWaa-MwWWQAX-pnMtW&tp=1&oh=77eec95c87a2bbe98c4711b455336e5e&oe=5FE5934A

note: the print line works fine and gives the full link.
I want to know how can I let the !wget -P take the full link in this case.

I am new here, so excuse me if I made any mistake by not following the regulations correctly.

Thanks

Source: Python Questions

LEAVE A COMMENT