Download File Và Torrent Vào Google Drive Bằng Cách Dùng Google Colab
#TOP
Google Colab1. Đăng nhập vào Google Colab và tạo Python3 notebook mới.


2. Bật chế độ GPU (Nếu file muốn download lớn)
Chọn Edit > Notebook settings hoặc Runtime>Change runtime type và chọn GPU as Hardware accelerator.

Tiếp theo ta cần mount Google Drive để file có thể lưu vào Google Drive
from google.colab import drive
drive.mount('/content/gdrive')
Sau đó, ta sẽ thấy một đường link. Hãy nhấp vào nó và cho phép truy cập. Copy mã xuất hiện và paste vào ô, rồi nhấn enter.




Để download thì chạy đoạn code này:
import requests
file_url = "http://1.droppdf.com/files/5iHzx/automate-the-boring-stuff-with-python-2015-.pdf"
r = requests.get(file_url, stream = True)
with open("/content/gdrive/My Drive/python.pdf", "wb") as file:
for block in r.iter_content(chunk_size = 1024):
if block:
file.write(block)
[u]Download Torrent File[/u]
Ở đây ta sử dụnghttps://github.com/FKLC/Torrent-To-Google-Drive-Downloader
Và tác giả của notebook này khuyên không nên dùng nó vì chống lại chính sách của Google Colab =)))
Để sử dụng truy cập:https://colab.research.google.com/github/FKLC/Torrent-To-Google-Drive-Downloader/blob/master/Torrent_To_Google_Drive_Downloader.ipynb
Sưu tầm và tổng hợp~
Chủ yếu là từ bài này:https://www.geeksforgeeks.org/download-anything-to-google-drive-using-google-colab/
0 comments: