User:Pedro Sá Couto/Prototyping 5th/LibGen FTP uploader
< User:Pedro Sá Couto | Prototyping 5th
Revision as of 17:00, 19 January 2020 by Pedro Sá Couto (talk | contribs)
Library Genesis FTP Uploader
Using python's ftplib we are able to anonymously upload the Library Genesis.
Items can be uploaded in bulk, no need to use LibGen GUI.
import ftplib
from ftplib import FTP
import os
import fileinput
# connect to host, default port
ftp = FTP('ftp.libgen.lc')
# user anonymous, passwd anonymous@
ftp.login()
#change to the directory upload
ftp.cwd('upload')
#list all the directory
ftp.retrlines('LIST')
#change to the directory upload of books
ftp.cwd('/upload/_books/')
#check what is the directory we are in
ftp.pwd()
#ask in terminal for the file that is going to be uploaded
localfile = (input("What file do you want to upload? (include extention as example.pdf): "))
#use the file from the input, read binary
fp = open(localfile, 'rb')
#1024 is the block size
ftp.storbinary('STOR %s' % os.path.basename(localfile), fp, 1024)
# close file and FTP session
fp.close()
ftp.quit()