This repository has been archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27ffd11
commit 5136a6b
Showing
10 changed files
with
82 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
import scrapy | ||
|
||
from coinincome.items import CoinincomeItem | ||
from coinincome.utils import calculate_unit | ||
|
||
|
||
class F2poolSpider(scrapy.Spider): | ||
name = 'f2pool' | ||
allowed_domains = ['f2pool.com'] | ||
start_urls = ['https://f2pool.com/'] | ||
start_urls = ['https://www.f2pool.com/'] | ||
|
||
def parse(self, response): | ||
for project in response.xpath('//div/div/section/div/div/table/tbody/a[@class="btn-calculator"]'): | ||
if project.extract() != '#': | ||
print('https://www.f2pool.com%s' % project.extract()) | ||
|
||
for coin_config in response.xpath( | ||
'//tr[contains(@class, "row-common")]/td/a[contains(@class, "btn-calculator")]/@data-config'): | ||
if coin_config.extract() != '': | ||
coin = json.loads(coin_config.extract()) | ||
item = CoinincomeItem() | ||
item['coin'] = coin['currency'].lower() | ||
item['income_coin'] = float(coin['estimatedProfit']) | ||
item['income_hashrate_unit'] = coin['scale'] | ||
item['income_hashrate_unit_num'] = calculate_unit(coin['scale']) | ||
item['next_income_coin'] = 0 | ||
item['pool_name'] = self.name | ||
item['request_url'] = response.url | ||
yield item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
import scrapy | ||
|
||
from coinincome.items import CoinincomeItem | ||
from coinincome.utils import calculate_unit | ||
|
||
|
||
class ViabtcSpider(scrapy.Spider): | ||
name = 'viabtc' | ||
allowed_domains = ['viabtc.com'] | ||
start_urls = ['http://pool.viabtc.com/'] | ||
start_urls = ['https://pool.viabtc.com/'] | ||
|
||
def parse(self, response): | ||
pass | ||
# coinname = response.xpath('//div/div[@style="max-width:160px;"]/text()') | ||
coinname = response.xpath('//div/div[@class="m-l-10"]/text()') | ||
for coin in coinname.extract(): | ||
if coin.startswith("¥"): | ||
continue | ||
income_str_list = coin.split() | ||
income_hashrate_unit = income_str_list[0][0] | ||
standard_units = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"] | ||
if income_hashrate_unit not in standard_units: | ||
income_hashrate_unit = "" | ||
item = CoinincomeItem() | ||
item['coin'] = income_str_list[3].lower() | ||
item['income_coin'] = float(income_str_list[2]) | ||
item['income_hashrate_unit'] = income_hashrate_unit | ||
item['income_hashrate_unit_num'] = calculate_unit(income_str_list[0][0]) | ||
item['next_income_coin'] = 0 | ||
item['pool_name'] = self.name | ||
item['request_url'] = response.url | ||
yield item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
def calculate_unit(unit): | ||
units = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"] | ||
index = 0 | ||
while True: | ||
if unit == units[index]: | ||
break | ||
index = index + 1 | ||
return pow(1000, index) |