Skip to content

Instantly share code, notes, and snippets.

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

clark luzihang123

🎯
疯狂撸码
  • Shanghai
View GitHub Profile
@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',
@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 / 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 / auto_extract.py
Created September 9, 2019 10:58
智能解析文章
import requests
import json
headers = {
'Accept': 'application/json',
'Referer': 'https://scrapinghub.com/autoextract',
'Origin': 'https://scrapinghub.com',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
'Sec-Fetch-Mode': 'cors',
'Content-Type': 'application/json',
}
@luzihang123
luzihang123 / get_next_week.py
Last active October 25, 2019 08:40
计算临近(包含今天)的星期几的日期
import calendar
import datetime
choose_week = {'1': 'MONDAY',
'2': 'TUESDAY',
'3': 'WEDNESDAY',
'4': 'THURSDAY',
'5': 'FRIDAY',
'6': 'SATURDAY',
'7': 'SUNDAY', }
@luzihang123
luzihang123 / jd_union_api.py
Created February 23, 2020 03:32 — forked from socrateslee/jd_union_api.py
京东联盟开放平台API的一个通用的Client封装
'''
京东联盟开放平台API的一个通用的Client封装。
京东联盟开放平台的文档详见 https://union.jd.com/openplatform
Example:
client = JdApiClient("<YOUR_APP_KEY>", "<YOUR_SECRET_KEY>")
resp = client.call("jd.union.open.goods.promotiongoodsinfo.query",
{'skuIds':'12072066'})
print(resp.json())
'''
'''
Created on Apr 7, 2020
@author: admin
PyAutoGUI是一个纯Python的GUI自动化工具,其目的是可以用程序自动控制鼠标和键盘操作,多平台支持(Windows,OS X,Linux)。可以用pip安装,Github上有源代码。
下面的代码让鼠标移到屏幕中央。
'''
import pyautogui, time, pyperclip
@luzihang123
luzihang123 / selenium_ua.py
Created May 14, 2020 07:04
selenium 远端/本地 替换UA 测试代码
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import requests
import logging
def test_chrome_server(host):
"""
主动调用,等待docker容器内chrome浏览器server启动
:return:
@luzihang123
luzihang123 / gsxt_pyppeteer.py
Created June 3, 2020 11:09
pyppeteer访问国家企业信用,渲染页面
import asyncio
from pyppeteer import launch
import jsonpath
import random
from scrapy.selector import Selector
from pyquery import PyQuery as pq
merchant_list = {
"data":
[
{
@luzihang123
luzihang123 / selenium_gird_no_webdriver.py
Last active July 23, 2020 01:44
在selenium gird远端中去除webdriver特征
# https://blog.csdn.net/u014291399/article/details/106636619
from selenium.webdriver.chrome.remote_connection import ChromeRemoteConnection
from selenium import webdriver
import time
chromeOptions = webdriver.ChromeOptions()
# chromeOptions.add_argument('-headless') # 设为无头模式
# chromeOptions.add_argument('--user-agent=Mozilla/5.0 HAHA') # 配置对象添加替换User-Agent的命令
chromeOptions.add_argument('--disable-infobars') # 去掉提示:Chrome正收到自动测试软件的控制
chromeOptions.add_experimental_option('excludeSwitches', ['enable-automation'])
chromeOptions.add_experimental_option('useAutomationExtension', False)