Skip to content

Instantly share code, notes, and snippets.

View luzihang123's full-sized avatar
🎯
疯狂撸码

clark luzihang123

🎯
疯狂撸码
  • Shanghai
View GitHub Profile
@luzihang123
luzihang123 / sensitive_pic.py
Created November 2, 2018 09:23
爬虫敏感图片的识别与过滤
from functools import reduce
from PIL import Image
import requests
# 计算pHash(只需要三行):
def phash(img):
img = img.resize((8, 8), Image.ANTIALIAS).convert('L')
avg = reduce(lambda x, y: x + y, img.getdata()) / 64.
return reduce(
lambda x, y: x | (y[1] << y[0]),
@luzihang123
luzihang123 / eth_address_balance_0.py
Created October 9, 2018 03:53
requests 从infura API获取地址余额 demo
# curl -G https://api.infura.io/v1/jsonrpc/mainnet/eth_getBalance --data-urlencode 'params=["0xc94770007dda54cF92009BFF0dE90c06F603a09f","latest"]'
import requests
import urllib
params_str = '["{}","latest"]'.format('0xc94770007dda54cF92009BFF0dE90c06F603a09f')
params_encode = urllib.parse.quote(params_str)
r = requests.get(
url="https://api.infura.io/v1/jsonrpc/mainnet/eth_getBalance?params={}".format(params_encode),
)
print(r.json())
balance = int(r.json()["result"],16)
@luzihang123
luzihang123 / eth_address_balance.py
Last active July 20, 2019 09:11
异步从链上获取ETH余额 address ETH balance
import grequests
import urllib
address_list = [
"0xc94770007dda54cF92009BFF0dE90c06F603a09f",
'0x054c64741dbafdc19784505494029823d89c3b13',
'0x0b4bdc478791897274652dc15ef5c135cae61e60',
'0x4af328c52921706dcb739f25786210499169afe6',
'0x49bd2da75b1f7af1e4dfd6b1125fecde59dbec58',
'0x829bd824b016326a401d083b33d092293333a830',