def __init__(self, isbn_list, mirrors=[ "http://libgen.io/", "http://gen.lib.rus.ec/", "http://libgen.net/", "http://bookfi.org/" ]): self.mirrors = mirrors self.lg = libgenapi.Libgenapi(mirrors) self.isbn_list = isbn_list
def api_id(name): lg = libgenapi.Libgenapi(["http://libgen.io/", "http://gen.lib.rus.ec"]) #name=input("Enter the name of the book: ") output = lg.search(name) #json_output=json.load(output) json_output = json.dumps(output, sort_keys=True, indent=4) #print(json_output) loaded_data = json.loads(json_output) result = [] for data in loaded_data: if (data["mirrors"] != None ): # and (data["extension"]=="pdf" or data["extension"]=="epub")): for mirror in data["mirrors"]: if (mirror.startswith("http://libgen.pw")): print(mirror) name, url = url_opener(mirror) print(name) print(url) result.append({"name": name, "url": url}) print("\n\n") result = json.dumps(result, indent=2) return (result)
def books3(): lg=libgenapi.Libgenapi(["http://gen.lib.rus.ec"]) r = lg.search(session['interest3'],1) return render_template('books_interest2.html',result=r)
#!/usr/bin/env python3 import sys, json, os import libgenapi l = libgenapi.Libgenapi(["http://gen.lib.rus.ec/", "http://libgen.io/"]) query = " ".join(sys.argv[1:]) if os.getenv('DEBUGME', '') != '': print("query: " + query, file=sys.stderr) print(json.dumps(l.search(query))) # l.search("Michael","author")
import libgenapi import pandas as pd from pylibgen import Library MIRRORS = [ 'http://libgen.io/', 'https://libgen.unblocked.cab/', 'https://libgen.immunicity.cab/', 'https://libgen.unblockall.xyz/', 'https://libgen.unblocked.team/' ] lg = libgenapi.Libgenapi(MIRRORS) df = pd.DataFrame(lg.search("Portuguese",'language')) print(df.head())
import json import requests import time import urllib import libgenapi import FileInteractions TOKEN = "<Bot_Token>" URL = "https://api.telegram.org/bot{}/".format(TOKEN) FileObj = FileInteractions.FileInteractions() LIBGENOBJ = libgenapi.Libgenapi(FileObj.readmirrors()) def get_url(url): response = requests.get(url) content = response.content.decode('utf8') return content def get_json_from_url(url): content = get_url(url) js = json.loads(content) return js def get_updates(offset=None): url = URL + "getupdates?timeout=100" if offset: url += "&offset={}".format(offset) js = get_json_from_url(url) return js
import urllib.parse import urllib.request import webbrowser import isbnlib import libgenapi import requests from bs4 import BeautifulSoup # import subprocess # import os # please set a libgen domain before usage! libgendomain = "" libgen = libgenapi.Libgenapi(libgendomain) # "ping" function which is actually just checking for a response code of 200 def ping(address): if (urllib.request.urlopen(address).getcode() == 200): return True else: return False def cleanhtml(raw_html): cleanr = re.compile('<.*?>') cleantext = re.sub(cleanr, '', raw_html) return cleantext
def search(self, query, max_results=10, timeout=60): lg = libgenapi.Libgenapi([ "http://libgen.io", "http://gen.lib.rus.ec", "http://93.174.95.27/", "http://libgen.in", "http://libgen.org" ]) try: results = lg.search(query) abort = False print 'Reached LibGen Mirrors.' except: print 'LibGenAPI crashed. In most cases this is caused by unreachable LibGen Mirrors, try again in a few minutes.' raise abort = True counter = 0 br = browser() if not abort: for i in results: r = results[counter] s = SearchResult() s.title = r['title'] s.author = r['author'] s.price = '$0.00' s.drm = SearchResult.DRM_UNLOCKED extension = r['extension'] # prep cover coverpage = 'http://gen.lib.rus.ec' + r['mirrors'][1] coverpage = coverpage.replace('ads.', 'book/index.') with closing(br.open(coverpage, timeout=10)) as f: doc = f.read() linkpos = doc.find('/covers') linkend = doc.find('.jpg') + 4 cover = doc[linkpos:linkend] cover = 'http://gen.lib.rus.ec' + cover s.cover_url = cover # prep download via libgen lgpage = 'http://libgen.io' + r['mirrors'][1] with closing(br.open(lgpage, timeout=10)) as f: doc = f.read() linkend = doc.find('><h2>DOWNLOAD') - 1 doc = doc[linkend - 100:linkend] linkpos = doc.find('http') libgendl = doc[linkpos:linkend] libgendl = libgendl.replace('amp;', '') libgenformat = 'libgen: .' + extension s.downloads[libgenformat] = libgendl # get download location from libgen.pw lgpw = r['mirrors'][0].replace('view', 'download') with closing(br.open(lgpw, timeout=10)) as f: doc = f.read() pos = doc.find('location') + 16 end = doc.find('status') - 27 location = doc[pos:end] # prep filename filename = r['author'] + ' - ' + r['title'] filename = filename.replace(' ', '_') filename = filename.encode('utf8') filename = urllib2.quote(filename) # prep download via b-ok (/bookzz/boosc/bookza) bokdl = 'http://dlx.b-ok.org/genesis/' + location + '/_as/' + filename + '.pdf' bokformat = 'b-ok: .' + extension s.downloads[bokformat] = bokdl # prep download via bookfi bookfidl = 'http://dl.lux.bookfi.net/genesis/' + location + '/_as/' + filename + '.pdf' bookfiformat = 'bookfi: .' + extension # s.downloads[bookfiformat] = bookfidl s.formats = libgenformat + ', ' + bokformat + ', ' + bookfiformat + ',' yield s counter = counter + 1