def __init__(self, video_no): self.video_no = video_no = video_no.lower() # 年龄检查页 data = { 'age_gate': '1', 'age_gate[age]': 'TVRnPQ==', 'action': 'age_gate_submit', 'age_gate[nonce]': '7d70b59573', '_wp_http_referer': '/all/shn-016/', 'confirm_action': '0' } age_check_headers = { # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', # 'Accept-Encoding': 'gzip, deflate, br', # 'Accept-Language': 'en-US,en;q=0.9', # 'Cache-Control': 'max-age=0', # 'Connection': 'keep-alive', # 'Content-Length': '162', # 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': '_ga=GA1.3.488997533.1609657427; _gid=GA1.3.1979187914.1609657427; _gat=1', 'Host': 'www.naturalhigh.co.jp', 'Origin': 'https://www.naturalhigh.co.jp', 'Referer': 'https://www.naturalhigh.co.jp/all/shn-016/', # 'Sec-Fetch-Dest': 'document', # 'Sec-Fetch-Mode': 'navigate', # 'Sec-Fetch-Site': 'same-origin', # 'Sec-Fetch-User': '******', # 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' } http.post('https://www.naturalhigh.co.jp/wp-admin/admin-post.php', data=data, headers=age_check_headers) # 视频详情页html url = 'https://www.naturalhigh.co.jp/all/' + video_no + '/' response = http.get(url, self.headers) html = response.text soup = BeautifulSoup(html, features="html.parser") # poster self.poster_url = soup.find('img', class_="sam160")['src'] self.poster_name = os.path.basename(self.poster_url) self.poster_ext = os.path.splitext(self.poster_name)[1] # fanart self.fanart_url = soup.find('a', class_="popup-image")['href'] self.fanart_name = os.path.basename(self.fanart_url) self.fanart_ext = os.path.splitext(self.fanart_name)[1]
def __init__(self, video_no): self.video_no = video_no # 搜索列表 list_url = 'https://smt.hmp.jp/list.php' list_data = {'key': video_no} list_response = http.post(list_url, list_data, self.headers) list_html = list_response.text list_soup = BeautifulSoup(list_html, features="html.parser") # poster self.poster_url = self.site_url.rstrip('/') + list_soup.find( 'p', class_="mainImg").find('img')['data-original'] self.poster_name = os.path.basename(self.poster_url) self.poster_ext = os.path.splitext(self.poster_name)[1] # 详情页 url = self.site_url.rstrip('/') + list_soup.find( 'p', class_="mainImg").find('a')['href'] response = http.get(url, self.headers) html = response.text soup = BeautifulSoup(html, features="html.parser") # fanart self.fanart_url = self.site_url.rstrip('/') + soup.find( 'p', class_="mainImg").find('img')['src'] self.fanart_name = os.path.basename(self.fanart_url) self.fanart_ext = os.path.splitext(self.fanart_name)[1]
def get_unpaid_block(): unpaid_blocks = None producers_api = api + '/v1/chain/get_producers' response = http.post(producers_api, producers_api, data='{"json":true,"limit":21}') for data in response.json()['rows']: if data['owner'] == bp_name: unpaid_blocks = int(data['unpaid_blocks']) break return unpaid_blocks
def get_block(block_num_or_id, url=def_api, timeout=def_timeout): uri = "/v1/chain/get_block" url = url + uri data = """ { "block_num_or_id": "%s" } """ % (block_num_or_id) return http.post('get_block', url=url, data=data, timeout=timeout).json()
def get_bindname_info(bidname): params = '{"scope":"eosio",' \ '"table":"namebids",' \ '"json":true,' \ '"code":"eosio",' \ '"limit":1,' \ '"lower_bound":"%s"}' % bidname response = http.post('bidname', api, data=params) handle_reponse(bidname, response.json())
def save(config, page): if not config.enableStore: return url = config.storeApi res = http.post(url, page.toDict()) data = res
def get_currency_stats(url=def_api, symbol='EOS', code='eosio.token', timeout=def_timeout): uri = "/v1/chain/get_currency_stats" url = url + uri data = """ { "symbol": "%s", "code": "%s" } """ % (symbol, code) response = http.post(uri, url, data=data, timeout=timeout) return response.json()[symbol]
def get_actions(account, pos=-1, offset=-50, url=def_api, timeout=def_timeout): uri = "/v1/history/get_actions" url = url + uri data = """ { "account_name": "%s", "pos": %s, "offset": %s } """ % (account, pos, offset) return http.post('get_actions', url=url, data=data, timeout=timeout).json()['actions']
def get_issue_token(): global pervote_bucket, perblock_bucket currency_url = url + "/v1/chain/get_currency_stats" response = http.post(currency_url, currency_url, data='{"symbol":"EOS","code":"eosio.token"}') supply = float(response.json()['EOS']['supply'][:-4]) usecs_since_last_fill = ct - last_pervote_bucket_fill new_tokens = continuous_rate * supply * usecs_since_last_fill / useconds_per_year to_producers = new_tokens / 5 to_per_block_pay = to_producers / 4 to_per_vote_pay = to_producers - to_per_block_pay pervote_bucket = pervote_bucket + to_per_vote_pay perblock_bucket = perblock_bucket + to_per_block_pay
def get_global_info(): global total_vote_weight, pervote_bucket, total_unpaid_blocks, perblock_bucket, last_pervote_bucket_fill global_url = url + "/v1/chain/get_table_rows" response = http.post( global_url, global_url, data= '{"scope":"eosio","table":"global","json":true,"code":"eosio","limit":1}' ) global_data = response.json()['rows'][0] total_vote_weight = float(global_data['total_producer_vote_weight']) pervote_bucket = int(global_data['pervote_bucket']) perblock_bucket = int(global_data['perblock_bucket']) total_unpaid_blocks = int(global_data['total_unpaid_blocks']) last_pervote_bucket_fill = int(global_data['last_pervote_bucket_fill'])
def get_table_rows(table, scope='eosio', code='eosio', limit=1, lower_bound='', url=def_api, timeout=def_timeout): uri = "/v1/chain/get_table_rows" url = url + uri data = """ { "scope": "%s", "table": "%s", "code": "%s", "limit": %s, "lower_bound":"%s" "json": true } """ % (scope, table, code, limit, lower_bound) response = http.post(uri, url, data=data, timeout=timeout) return response.json()['rows']
def get_account_info(): global bp_vote_weight, unpaid_blocks, last_claim_time, rank find_bp = False producers_api = url + "/v1/chain/get_producers" response = http.post(producers_api, producers_api, data='{"json":true,"limit":1000}') for data in response.json()['rows']: if data['owner'] == bp_name: bp_vote_weight = float(data['total_votes']) unpaid_blocks = int(data['unpaid_blocks']) last_claim_time = int(data['last_claim_time']) find_bp = True break rank = rank + 1 if not find_bp: logger.info("%s not found." % (bp_name)) return
def get_producers(url=def_api, account=None, limit=21, timeout=def_timeout): uri = "/v1/chain/get_producers" url = url + uri data = """ { "json":true, "limit":%s } """ % limit response = http.post(uri, url, data=data, timeout=timeout) if account is None: return response.json()['rows'] rank = 0 producer_info = None for producer in response.json()['rows']: rank = rank + 1 if producer['owner'] == account: producer_info = producer producer_info['rank'] = rank return producer_info