def _requestUrl(self, url, method, data=None): """Request an URL. Args: url: The web location we want to retrieve. method: Either POST or GET. data: A dict of (str, unicode) key/value pairs. Returns: A JSON object. """ if method == "POST": if ( "audio" in data and is_file(data["audio"]) or "document" in data and is_file(data["document"]) or "photo" in data and is_file(data["photo"]) or "video" in data and is_file(data["video"]) ): try: data = InputFile(data) request = urllib.request(url, data=data.to_form(), headers=data.headers) return urllib.request.urlopen(request).read() except urllib.error.URLError as e: raise TelegramError(str(e)) else: try: return urllib.request.urlopen(url, urllib.parse.urlencode(data).encode()).read() except urllib.error.URLError as e: raise TelegramError(str(e)) if method == "GET": try: return urllib.request.urlopen(url).read() except urllib.error.URLError as e: raise TelegramError(str(e)) return 0
def get(self): """REST GET implementation for the URI: http://<server>:<port>/resource?httpurl=<string:httpurl> Parameters ---------- httpurl: str (required) the HTTP URL for the resource to retrieve Raises: ------ BadRequest if HTTP URL is not valid """ params = request.args if not params: raise BadRequest("Parameters httpurl=<httpurl> is missing") if "httpurl" not in params: raise BadRequest("Missing required httpurl parameter") url = params.get("httpurl") req = urllib.request(url) try: resp = urllib.request.urlopen(req, timeout=5) except urllib.error.URLError as err: sys.stderr.write(str(err)) raise BadRequest(("URL request to httpurl=[{0}] failed: [{1}] ") .format(url, err)) page = resp.read().strip() soup = BeautifulSoup(page, 'html.parser') html = soup.prettify() data = OrderedDict() data[URL_KEY] = url data[DATA_KEY] = html json_response = jsonify(data) return json_response
hyip.addPayment_method('Bankwire') else: six.print_('payment methods parsed') six.print_(small2) six.print_(cl2) six.print_(tabl0) output(hyip) elif method == 'mechanize': six.print_( 'Not supported yet! Use native or dont define @method at all') elif method == 'urllib2': six.print_( 'Not supported yet! Use native or dont define @method at all') exit(1) req = urllib.request(goldpoll_url) # urllib2.Request(goldpoll_url) response = urllib.urlopen(req) # urllib2.urlopen(req) the_page = response.read() webpage = the_page.decode("ISO-8859-1") parser = etree.HTMLParser() tree = etree.fromstring(webpage, parser) elements_c10 = tree.xpath('//table[@class="cl0"]') six.print_(elements_c10) if 'popularhyip' in sites: if method == 'static': dir_separator = ('\\' if is_windows() else '/') doc = html.parse('input' + dir_separator + geckoname) #print etree.tostring(doc) elements_status1 = doc.xpath( '//tr[@class="status1" and (not(@id))]') six.print_(len(elements_status1))
elif (content['src'] is not None) and ('/small.gif' in content['src']): #index = cl2.index(content) + 1 hyip.addPayment_method('Bankwire') else: six.print_('payment methods parsed') six.print_(small2) six.print_(cl2) six.print_(tabl0) output(hyip) elif method == 'mechanize': six.print_('Not supported yet! Use native or dont define @method at all') elif method == 'urllib2': six.print_('Not supported yet! Use native or dont define @method at all') exit(1) req = urllib.request(goldpoll_url) # urllib2.Request(goldpoll_url) response = urllib.urlopen(req) # urllib2.urlopen(req) the_page = response.read() webpage = the_page.decode("ISO-8859-1") parser = etree.HTMLParser() tree = etree.fromstring(webpage, parser) elements_c10 = tree.xpath('//table[@class="cl0"]') six.print_(elements_c10) if 'popularhyip' in sites: if method == 'static': dir_separator = ('\\' if is_windows() else '/') doc = html.parse('input' + dir_separator + geckoname) #print etree.tostring(doc) elements_status1 = doc.xpath('//tr[@class="status1" and (not(@id))]') six.print_(len(elements_status1)) for element in elements_status1: