File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99ID_REGEX = "\?id=[0-9]+"
1010
11- import requests
12- import json
13- from collections import namedtuple
1411from lxml import etree
15-
1612import re
13+ import urllib
14+ import urllib2
15+
16+ DEFAULT_FIELDS = "Title,Author,ID,MD5"
17+
18+ LIBGEN_URL = "http://libgen.io/foreignfiction/"
19+
20+ BOOK_ENDPOINT = "json.php?ids={0}&fields={1}"
21+ DOWNLOAD_URL = "get.php?md5={0}"
22+ SEARCH_URL = "index.php"
23+
24+ ID_REGEX = "\?id=[0-9]+"
1725
1826
1927def _json_object_hook (d ): return namedtuple ('X' , d .keys ())(* d .values ())
@@ -103,14 +111,16 @@ def search(self, query):
103111 'f_group' : 1
104112 }
105113
106- response = requests .get (url , params = query_params )
114+ query_string = urllib .urlencode (query_params )
115+ request = urllib2 .request (url + '?' + query_string )
116+ html = request .read ()
107117
108118 parser = etree .HTMLParser ()
109- tree = etree .fromstring (response . text , parser )
119+ tree = etree .fromstring (params , parser )
110120
111121 return LibgenSearchResults .parse (tree )
112122
113123
114124if __name__ == "__main__" :
115- client = LibgenClient ()
125+ client = LibgenFictionClient ()
116126 result = client .search ("Stormlight Archive" )
You can’t perform that action at this time.
0 commit comments