Skip to content

Commit

Permalink
Merge pull request rachmadaniHaryono#20 from rachmadaniHaryono/featur…
Browse files Browse the repository at this point in the history
…e/print-url
  • Loading branch information
rachmadaniHaryono authored Apr 24, 2020
2 parents aeec72f + 2875166 commit a5db9ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion we_get/core/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import urllib.request
import urllib.parse
from urllib.error import URLError
from we_get.core.utils import random_user_agent
from html import unescape as html_decode

Expand All @@ -21,7 +22,12 @@ def http_get_request(self, url):
"""
opener = urllib.request.build_opener()
opener.addheaders = [('User-Agent', USER_AGENT), ("Accept", "*/*")]
return opener.open(url).read().decode()
try:
res = opener.open(url).read().decode()
return res
except URLError as err:
print('Error when opening following url.\n{}'.format(url))
raise err

def http_custom_get_request(self, url, headers):
""" http_custom_get_request: HTTP GET request with custom headers.
Expand Down
3 changes: 2 additions & 1 deletion we_get/modules/1337x.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
See the file 'LICENSE' for copying permission
"""

from urllib.parse import quote_plus
from we_get.core.module import Module
import re

Expand Down Expand Up @@ -54,7 +55,7 @@ def set_item(self, link):
return item

def search(self):
url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query))
url = "%s%s" % (BASE_URL, SEARCH_LOC % (quote_plus(self.search_query)))
data = self.module.http_get_request(url)
links = re.findall(r'href=[\'"]?([^\'">]+)', data)
results = 0
Expand Down
4 changes: 2 additions & 2 deletions we_get/modules/the_pirate_bay.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from we_get.core.module import Module
import re

BASE_URL = "https://thepiratebay.org"
SEARCH_LOC = "/search/%s/0/99/0"
BASE_URL = "https://www1.thepiratebay3.to"
SEARCH_LOC = "/search/%s/1/7/0"
LIST_LOC = "/top/all"


Expand Down

0 comments on commit a5db9ac

Please sign in to comment.