Last active
October 17, 2017 19:49
-
-
Save theotheo/5bb724b8062702f08a1268f3a265d137 to your computer and use it in GitHub Desktop.
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
from bs4 import BeautifulSoup | |
import requests | |
import html5lib | |
import lxml | |
import urllib3 | |
NUMBERS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"] | |
ICOBENCH_URL = "https://icobench.com/icos?page={num}" | |
#loop for getting all the ongoing, past and future ico links | |
projects_names = [] | |
for num in NUMBERS: | |
res = requests.get(ICOBENCH_URL.format(num=num)) | |
if res.status_code == 200: | |
tree = BeautifulSoup(res.text, "lxml") | |
for div in tree.find_all(class_="content"): #список всех блоков класса с инфо по ico | |
projects_names.append(div.a.get('href')) | |
else: | |
print("Error in page num" + num) | |
len(projects_names) | |
ICOBENCH_ICO_URL = "https://icobench.com/{project}" | |
#ICO_info: луп, который выгружает название, дату и размер сборов | |
ICO_info = {} | |
for project in projects_names: | |
res = requests.get(ICOBENCH_ICO_URL.format(project=project)) | |
if res.status_code == 200: | |
tree = BeautifulSoup(res.text, "html5lib") | |
for project in tree.find_all("div", class_="name"): | |
if not (project.h1): | |
continue | |
name = project.h1.string | |
ICO_info['name'] = name | |
for project in tree.find_all("div", class_="col_2 expand"): | |
if not (project.small): | |
continue | |
date = project.small.string | |
ICO_info['date'] = date | |
for project in tree.find_all("div", class_="raised"): | |
raised = project.string | |
ICO_info['raised'] = raised | |
financial_data_node = tree.find("div", class_="financial_data") | |
for data_row_node in financial_data_node.find_all("div", class_="data_row"): | |
kind_node, data_node = data_row_node.find_all('div', class_='col_2') | |
kind, data = kind_node.text.strip().lower(), data_node.text.strip() | |
ICO_info[kind] = data | |
else: | |
raise Exception("Error") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment