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 |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Library Genesis FTP Uploader= | |||
====From the git==== | |||
https://git.xpub.nl/pedrosaclout/LibGen_FTP_Uploader | |||
<br><br> | |||
Using python's ftplib we are able to anonymously upload into Library Genesis.<br> | |||
Items can be uploaded in bulk, no need to use LibGen GUI. | |||
<source lang="python"> | <source lang="python"> |
Latest revision as of 18:02, 19 January 2020
Library Genesis FTP Uploader
From the git
https://git.xpub.nl/pedrosaclout/LibGen_FTP_Uploader
Using python's ftplib we are able to anonymously upload into 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()