Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile tox #74

Merged
merged 14 commits into from
Jul 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ wechatsogou/ocr
sprider
wechatsogou.egg-info
dist
demo/yu_save.py
demo/wechatsogou
demo
log.txt
web
wechatid.txt
.DS_Store
test/config.py
.python-version
.python-version
*.pyc
.tox/
build/
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: python

python:
- 3.6
- "2.7.12"
- "3.5.3"
- "3.6.1"

cache:
directories:
Expand All @@ -13,10 +15,18 @@ env:
- PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels

install:
- pip install tox tox-travis flake8
- pip install -r requirements.txt

before_script:
- export PYTHONPATH=$PYTHONPATH:$(pwd)

script:
- python -m nose -vs
- make flake8
- make dry_publish
- tox

notifications:
email:
on_success: never
on_failure: never
10 changes: 1 addition & 9 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
include LICENSE
include README.rst
include MANIFEST.in
recursive-include * Makefile
recursive-include * make.bat
recursive-include test *
recursive-include demo *
recursive-exclude * __pycache__
recursive-exclude screenshot *

graft docs
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: rst dry_publish

docdir = docs
rst:
if [ -a $(docdir)/README.rst ]; then rm $(docdir)/README.rst; fi;
pandoc --from=markdown --to=rst --output=$(docdir)/README.rst README.md
if [ -a $(docdir)/HISTORY.rst ]; then rm $(docdir)/HISTORY.rst; fi;
pandoc --from=markdown --to=rst --output=$(docdir)/HISTORY.rst CHANGELOG.md
python setup.py check --restructuredtext

dry_publish:
rm -rf dist/ build/
python setup.py sdist bdist_wheel

flake8:
flake8 --ignore=E501,F401,E128,E402,E731,F821 wechatsogou

tox:
pyenv local 2.7.12 3.5.3 3.6.1
tox

clean:
@rm -rf build/ wechatsogou.egg-info/ dist/
111 changes: 111 additions & 0 deletions docs/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Change Log
==========

`Unreleased <https://github.com/Chyroc/WechatSogou/tree/HEAD>`__
----------------------------------------------------------------

`Full
Changelog <https://github.com/Chyroc/WechatSogou/compare/v2.0.3...HEAD>`__

**Closed issues:**

- 微信搜索公众号结果模版改变了
`#51 <https://github.com/Chyroc/WechatSogou/issues/51>`__
- ImportError: cannot import name config
`#40 <https://github.com/Chyroc/WechatSogou/issues/40>`__

`v2.0.3 <https://github.com/Chyroc/WechatSogou/tree/v2.0.3>`__ (2016-12-18)
---------------------------------------------------------------------------

**Closed issues:**

- 引入模块的时候报错
`#33 <https://github.com/Chyroc/WechatSogou/issues/33>`__
- 导入文件后有bug
`#31 <https://github.com/Chyroc/WechatSogou/issues/31>`__
- 请问如何设置代理
`#27 <https://github.com/Chyroc/WechatSogou/issues/27>`__
- 请问最近搜狗返回的Html内容是改了吗?最近抓内容出错。
`#25 <https://github.com/Chyroc/WechatSogou/issues/25>`__
- 结果模版更新了
`#24 <https://github.com/Chyroc/WechatSogou/issues/24>`__
- 文章标题带引号(",&quot)的情况解析报错
`#23 <https://github.com/Chyroc/WechatSogou/issues/23>`__
- 请问,我运行test.py时为何没报错却没得到任何结果?
`#21 <https://github.com/Chyroc/WechatSogou/issues/21>`__
- 如何获得公众号的id和名称?
`#20 <https://github.com/Chyroc/WechatSogou/issues/20>`__
- search\_gzh\_info无法取得内容
`#18 <https://github.com/Chyroc/WechatSogou/issues/18>`__
- 原始文章url `#17 <https://github.com/Chyroc/WechatSogou/issues/17>`__
- 请问在Linux下可以使用吗?我运行了一下出现如下问题,还望指教
`#16 <https://github.com/Chyroc/WechatSogou/issues/16>`__
- log怎么使用?
`#15 <https://github.com/Chyroc/WechatSogou/issues/15>`__
- 抓取数据有时成功,有时失败
`#14 <https://github.com/Chyroc/WechatSogou/issues/14>`__
- 验证码打开失败问题原因是:
`#13 <https://github.com/Chyroc/WechatSogou/issues/13>`__
- 验证码输入后失败
`#12 <https://github.com/Chyroc/WechatSogou/issues/12>`__
- 获得的文章链接,如果打开需要验证码输入才跳转
`#11 <https://github.com/Chyroc/WechatSogou/issues/11>`__
- 获取文章只能10篇?
`#10 <https://github.com/Chyroc/WechatSogou/issues/10>`__
- 搜狗平台问题 `#9 <https://github.com/Chyroc/WechatSogou/issues/9>`__
- deal\_article\_comment(text=text)并不能获得用户的评论内容
`#8 <https://github.com/Chyroc/WechatSogou/issues/8>`__
- py2.7 什么时候支持?
`#7 <https://github.com/Chyroc/WechatSogou/issues/7>`__
- PIL is not support Python3
`#6 <https://github.com/Chyroc/WechatSogou/issues/6>`__
- 演示代码wechats.get\_gzh\_article\_by\_url\_dict(wechat\_info['url'])提示list
index out of range
`#5 <https://github.com/Chyroc/WechatSogou/issues/5>`__
- 如何使用代理 `#2 <https://github.com/Chyroc/WechatSogou/issues/2>`__
- 使用的是 python3 吗?
`#1 <https://github.com/Chyroc/WechatSogou/issues/1>`__

**Merged pull requests:**

- fix for ci `#50 <https://github.com/Chyroc/WechatSogou/pull/50>`__
(`Chyroc <https://github.com/Chyroc>`__)
- add readme.rst
`#48 <https://github.com/Chyroc/WechatSogou/pull/48>`__
(`Chyroc <https://github.com/Chyroc>`__)
- 添加安装说明 `#47 <https://github.com/Chyroc/WechatSogou/pull/47>`__
(`Chyroc <https://github.com/Chyroc>`__)
- upload to pypi
`#46 <https://github.com/Chyroc/WechatSogou/pull/46>`__
(`Chyroc <https://github.com/Chyroc>`__)
- add `#45 <https://github.com/Chyroc/WechatSogou/pull/45>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Add/api test `#44 <https://github.com/Chyroc/WechatSogou/pull/44>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Fix/re ocr for get gzh article by url text
`#43 <https://github.com/Chyroc/WechatSogou/pull/43>`__
(`Chyroc <https://github.com/Chyroc>`__)
- 修复首页热门获取单页
`#42 <https://github.com/Chyroc/WechatSogou/pull/42>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Fix/search article info
`#41 <https://github.com/Chyroc/WechatSogou/pull/41>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Add/readme zanshu
`#39 <https://github.com/Chyroc/WechatSogou/pull/39>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Fix/test ruokuai
`#38 <https://github.com/Chyroc/WechatSogou/pull/38>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Feature/test ruokuai
`#37 <https://github.com/Chyroc/WechatSogou/pull/37>`__
(`Chyroc <https://github.com/Chyroc>`__)
- Feature/update version
`#35 <https://github.com/Chyroc/WechatSogou/pull/35>`__
(`Chyroc <https://github.com/Chyroc>`__)
- add requirements.txt
`#34 <https://github.com/Chyroc/WechatSogou/pull/34>`__
(`Chyroc <https://github.com/Chyroc>`__)

\* *This Change Log was automatically generated by
`github\_changelog\_generator <https://github.com/skywinder/Github-Changelog-Generator>`__*
12 changes: 8 additions & 4 deletions README.rst → docs/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
基于搜狗微信搜索的微信公众号爬虫接口
====================================

|py27| |py35|
|Build Status| |PyPI version| |py36|

项目简介
========
Expand All @@ -17,6 +17,7 @@

赞助作者
========

甲鱼说,咖啡是灵魂的饮料,买点咖啡

谢谢:
Expand Down Expand Up @@ -421,6 +422,9 @@ TODO

--------------

.. |py27| image:: https://camo.githubusercontent.com/392a32588691a8418368a51ff33a12d41f11f0a9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d322e372d6666363962342e737667
.. |py35| image:: https://camo.githubusercontent.com/633acad03f4dbbaa8cca6bee5902207fd3b27a34/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e352d7265642e737667

.. |Build Status| image:: https://travis-ci.org/Chyroc/WechatSogou.svg?branch=master
:target: https://github.com/Chyroc/WechatSogou
.. |PyPI version| image:: https://badge.fury.io/py/wechatsogou.svg
:target: https://github.com/Chyroc/WechatSogou
.. |py36| image:: https://img.shields.io/pypi/pyversions/wechatsogou.svg
:target: https://github.com/Chyroc/WechatSogou
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
Flask==0.12.2
future==0.16.0
lxml==3.7.3
MarkupSafe==1.0
nose==1.3.7
Pillow==4.1.1
requests==2.14.2
six==1.10.0
Werkzeug==0.12.2
xlrd==1.0.0
zope.interface==4.4.1
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
62 changes: 35 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# -*- coding: utf-8 -*-
import codecs
from setuptools import setup

from setuptools import setup, find_packages
from codecs import open
from os import path
import wechatsogou

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
readme = codecs.open('docs/README.rst', encoding='utf-8').read()
history = codecs.open('docs/HISTORY.rst', encoding='utf-8').read()

setup(
name='wechatsogou',

version=wechatsogou.__version__,

description='api for wechat mp with sogou.',
long_description=long_description,

url='https://github.com/Chyroc/WechatSogou',

author='Chyroc Chen',
description='Api for wechat mp with sogou',
long_description=u'\n\n'.join([readme, history]),
author='Chyroc',
author_email='[email protected]',

license='MIT',

keywords='python web wechat sogou api weixin',

packages=find_packages(),

install_requires=['requests'],

extras_require={},
)
url='https://github.com/Chyroc/WechatSogou',
packages=[
'wechatsogou',
],
setup_requires=[
# minimum version to use environment markers
'setuptools>=20.6.8',
],
install_requires=[
'future', 'lxml', 'Pillow', 'requests', 'six', 'Werkzeug', 'xlrd'
],
include_package_data=True,
license='MIT License',
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7.12',
'Programming Language :: Python :: 3.5.3',
'Programming Language :: Python :: 3.6.1',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: Implementation :: CPython',
],
)
2 changes: 2 additions & 0 deletions test/TestTools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

import unittest
from nose.tools import assert_raises, assert_equal

Expand Down
1 change: 1 addition & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
15 changes: 15 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tox]
envlist = py27,py35,py36

[testenv]
deps=
setuptools==34.3.1
requests
lxml
future
Pillow
Werkzeug
nose
commands =
#python setup.py test
python -m nose -vs
6 changes: 2 additions & 4 deletions wechatsogou/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

import re
import time
import logging

import requests
Expand Down Expand Up @@ -338,9 +337,8 @@ def deal_article_comment(self, **kwargs):
sg_data = re.findall(u'window.sg_data={(.*?)}', text, re.S)
sg_data = '{' + sg_data[0].replace(u'\r\n', '').replace(' ', '') + '}'
sg_data = re.findall(u'{src:"(.*?)",ver:"(.*?)",timestamp:"(.*?)",signature:"(.*?)"}', sg_data)[0]
comment_req_url = 'http://mp.weixin.qq.com/mp/getcomment?src=' + sg_data[0] + '&ver=' + sg_data[
1] + '&timestamp=' + sg_data[2] + '&signature=' + sg_data[
3] + '&uin=&key=&pass_ticket=&wxtoken=&devicetype=&clientversion=0&x5=0'
comment_req_url = 'http://mp.weixin.qq.com/mp/getcomment?src={}&ver={}&timestamp={}&signature={}&uin=&key=&pass_ticket=&wxtoken=&devicetype=&clientversion=0&x5=0'.format(
*sg_data)
comment_text = self._get(comment_req_url, 'get', host='mp.weixin.qq.com', referer='http://mp.weixin.qq.com')
comment_dict = eval(comment_text)
ret = comment_dict['base_resp']['ret']
Expand Down
4 changes: 1 addition & 3 deletions wechatsogou/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
import random
import logging
from builtins import input
from future.builtins.misc import input

import requests
from lxml import etree
Expand All @@ -22,13 +22,11 @@
try:
import StringIO


def readimg(content):
return Image.open(StringIO.StringIO(content))
except ImportError:
import tempfile


def readimg(content):
f = tempfile.TemporaryFile()
f.write(content)
Expand Down
1 change: 0 additions & 1 deletion wechatsogou/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
# 缓存配置
cache_dir = 'cache'
cache_session_name = 'requests_wechatsogou_session'

1 change: 1 addition & 0 deletions wechatsogou/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-


class WechatSogouException(Exception):
"""基于搜狗搜索的的微信公众号爬虫接口 异常基类
"""
Expand Down