Skip to main content
思明的个人工具库
=================

该工具库主要是把我平时常用的SEO代码、数据采集代码进行封装,方便在不同的项目中引用。
如果你使用该工具库,本人无法保证代码的稳定性。


安装
======
pip install ysmtool


使用
======

import ysmtool

Http模块
=========

http=ysmtool.Http()

status,html=http.get("https://www.baidu.com")

有get 和 post 方法, 返回 (status,html) , status 为 请求返回的状态码,数值型。

ip:指定本地出口IP,如果是多网卡服务器,设置为相应网卡绑定的IP地址,就会从指定网卡进行请求

gbk:如果返回的源码是gb2312,gbk之类的,设置为True

serverIp:指定域名对应的IP,可以免解析,或者截持

ua: user_agent

cookie: cookie文本

serverPort:网站对应的端口

http.get(self,url,ip=None,ua='',refer='',cookie='',gbk=False,serverIp='',serverPort='')

http.post(self,url,ip=None,ua='',refer='',cookie='',data={},gbk=False,serverIp='',serverPort='')

tool模块
===========

bs=ysmtool.tool.soup(html)
将html转为BeautifulSoup对象

str=ysmtool.tool.urlencode(str)
对字符串进行url编码

md5str=ysmtool.tool.md5(str)
对字符串进行md5

jsontxt=ysmtool.tool.json_encode(obj)
对json对象转化成json字符串,出错时 jsontxt==None


obj=ysmtool.tool.json_decode(jsontxt)
解析json字符串,出错时 obj==None


baidu模块
=========

status,num=ysmtool.baidu.index('www.taobao.com')
淘宝的百度收录 , 正常返回的话, status == 200

status,result=ysmtool.baidu.search('连衣裙',1,10)
百度搜索“连衣裙”,返回第一页的结果, 正常返回的话, status == 200
第三个参数为每页显示条数,默认10,只能设置为10,20,30,40,50

if status==200 and result:
for item in result['items']:
print item['title'],item['url']

当查询为第1页时,result['total'] 为相关结果数:

status,result=ysmtool.baidu.search('site:www.yesiming.com',1)
if status==200 and result:
print result['total'] #收录数

凤巢关键词规划师拓词功能,需要网页端登录,然后抓包记录cookie和相关信息
每次最多返回1000个相关关键词,
kwc:竞争激烈程度
pv:整体日均搜索数
pcShow:pc搜索数
wiseShow:移动搜索数
showReason: 展现理由,数组结构 ['黑马','夜间好词']
totalWeight: 总权重,不知道什么鬼

reqid=''
eventId=''
token=''
userid=''
cookie=''

page=1
status,words=ysmtool.baidu.fengchao('双飞燕鼠标',cookie,token,userid,eventId,reqid,page)
if status==200:
for word in words:
print word['word'],word['kwc'],word['pv'],word['pcShow'],word['wiseShow'],word['showReason'],word['totalWeight']



haosou模块
==========

status,num=ysmtool.haosou.index('www.taobao.com')
淘宝的360收录 , 正常返回的话, status == 200

status,result=ysmtool.haosou.search('连衣裙',1)
360搜索“连衣裙”,返回第一页的结果 , 正常返回的话, status == 200

if status==200 and result:
for item in result['items']:
print item['title'],item['url']

当查询为第1页时,result['total'] 为相关结果数:

status,result=ysmtool.haosou.search('site:www.yesiming.com',1)
if status==200 and result:
print result['total'] #收录数

aizhan模块
===========

打印出最近半年淘宝在百度的收录情况
ysmtool.aizhan.history("www.taobao.com",'baidu')

返回淘宝最近半年的历史数据,包括百度收录,百度索引,百度反链,360收录,360反链,搜狗收录,搜狗反链, Json格式

json=ysmtool.aizhan.history('www.taobao.com')
if json:
print json

联系我
==========

有问题请发邮箱至 simon@yesiming.com
或者QQ: 176089710

Metadata

Release files for ysmtool 0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ysmtool 0.9
File Size Uploaded
ysmtool-0.9.tar.gz 6.9 kB Details

Release files / ysmtool-0.9.tar.gz

Download URL ysmtool-0.9.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a39629e64fb0b6d94e7fd39534169cd64b46d865ad8eaa455a0ce6ae4c04b587
BLAKE2b-256 checksum
How to use checksums
1254ebe8458ff12842324f250bd412b45f549c1ce667b739f75c34b636ea3f58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9 This release

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page