Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4. base = 'https://etherscan.io/tokenholdingsHandler.ashx?&a='
  5. # https://etherscan.io/tokenholdings?a=0x795476Fe57865598a85F28b1E53A430932E66CC1
  6. tail_menu = {
  7. 'add1': '0x3214973ADa17253048e14d712142b1dd09C25531&q=&p=1&f=0&h=1&sort=total_price_usd&order=desc&pUsd24hrs=&pBtc24hrs=&pUsd=&fav=',
  8.  
  9. }
  10.  
  11. def set_urls():
  12.     for x in tail_menu:
  13.         url = base + tail_menu.get(x)
  14.         send_url(url)
  15.  
  16.  
  17. def send_url(x):
  18.     request = requests.get(x)
  19.     response = str(request.content)
  20.     with open('test.html', 'w') as response_html:
  21.         response_html.write(response)
  22.  
  23.     htmlfile = open('test.html', 'r')
  24.     soup = BeautifulSoup(htmlfile, 'html.parser')
  25.     test = soup.find_all(htmlfile, '"totaleth"')
  26.     for tag in test:
  27.         print(tag.text.strip())
  28.     new_list = []
  29.     for y in test:
  30.         y = str(y)
  31.         y = y.split('>', 1)[-1]
  32.         y = y.split('<', 1)[0]
  33.         y = y.split('\'', 1)[0]
  34.         y = y.replace(u'\xa0', u'')
  35.         new_list.append(y)
  36.  
  37.     print('{} - {}'.format(x, new_list[2:][:2]))
  38.     with open('finaldata.text', 'a+') as storedata:
  39.         storedata.write('\n{} - {}'.format(x, new_list[2:][:2]))
  40.  
  41.  
  42.  
  43. set_urls()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement