User:Pedro Sá Couto/Prototyping 5th/LibGen FTP uploader: Difference between revisions
(Created page with " <source lang="python"> import ftplib from ftplib import FTP import os import fileinput # connect to host, default port ftp = FTP('ftp.libgen.lc') # user anonymous, passwd a...") |
No edit summary |
||
Line 1: | Line 1: | ||
=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 for a GUI. | |||
<source lang="python"> | <source lang="python"> |
Revision as of 18:00, 19 January 2020
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 for a 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()