protream / iquery Goto Github PK
View Code? Open in Web Editor NEWVarious information query via command line.
License: MIT License
Various information query via command line.
License: MIT License
iOS环境难以正常配置,想要一个node版的
install failed:
$ ./setup.py install
Traceback (most recent call last):
File "./setup.py", line 5, in <module>
from setuptools import setup
ImportError: No module named 'setuptools'
使用最新Github版安装 & pip3安装后,均找不到iquery命令,在系统环境变量目录找不到相关文件,之前的旧版ticket没有此问题。
$ iquery 南京 上海 910
Traceback (most recent call last):
File "d:\python3\lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "d:\python3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "d:\python3\Scripts\iquery.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'cli'
有个编码的错误,环境ubuntu server 16.04, python 2.7.11
Traceback (most recent call last):
File "/usr/local/bin/tickets", line 9, in <module>
load_entry_point('tickets==0.2.3', 'console_scripts', 'tickets')()
File "/usr/local/lib/python2.7/dist-packages/tickets/core.py", line 92, in cli
q.query().pretty_print()
File "/usr/local/lib/python2.7/dist-packages/tickets/trains.py", line 122, in pretty_print
for train in self.trains:
File "/usr/local/lib/python2.7/dist-packages/tickets/trains.py", line 83, in trains
colored.green(row.get('from_station_name')),
File "/usr/local/lib/python2.7/dist-packages/tickets/utils.py", line 134, in green
return self.color_str('GREEN', s)
File "/usr/local/lib/python2.7/dist-packages/tickets/utils.py", line 127, in color_str
self.RESET
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
查询参数
tickets 上海虹桥 北京 20160622
安装报错:
root@VM-102-99-debian:~# pip install tickets
Downloading/unpacking tickets
Could not find any downloads that satisfy the requirement tickets
No distributions at all found for tickets
Storing complete log in /root/.pip/pip.log
查看log文件:
root@VM-102-99-debian:~# cat /root/.pip/pip.log
/usr/bin/pip run on Sat Jun 11 21:57:15 2016
Downloading/unpacking ticketsGetting page http://pypi.python.org/simple/tickets
URLs to search for versions for tickets:
- http://pypi.python.org/simple/tickets/
Getting page http://pypi.python.org/simple/tickets/
Analyzing links from page https://pypi.python.org/simple/tickets/
Skipping link https://pypi.python.org/packages/79/bf/27ec9203a03d95e53d9ea530a1a3130c7e661a419c08fd98c16eca4e8797/tickets-0.1-py2-none-any.whl#md5=c75da25678bcbed13795eccff7eebd66 (from https://pypi.python.org/simple/tickets/); unknown archive format: .whl
Could not find any downloads that satisfy the requirement ticketsNo distributions at all found for tickets
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 104, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 245, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 978, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 157, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for tickets
我的系统是debian 7 32位:
root@VM-102-99-debian:~# cat /etc/debian_version
7.10
python 版本是2.7
root@VM-102-99-debian:~# python --version
Python 2.7.3
tickets 咸阳 音乐会
Traceback (most recent call last):
File "D:\Program Files\Python36\Scripts\tickets-script.py", line 9, in <module>
load_entry_point('tickets==0.2.3', 'console_scripts', 'tickets')()
File "D:\Program Files\Python36\lib\site-packages\tickets-0.2.3-py3.6.egg\tickets\core.py", line 92, in cli
q.query().pretty_print()
File "D:\Program Files\Python36\lib\site-packages\tickets-0.2.3-py3.6.egg\tickets\showes.py", line 170, in query
params = self._build_params()
File "D:\Program Files\Python36\lib\site-packages\tickets-0.2.3-py3.6.egg\tickets\showes.py", line 142, in _build_params
cityID=self._city_id, isText=1,
File "D:\Program Files\Python36\lib\site-packages\tickets-0.2.3-py3.6.egg\tickets\showes.py", line 112, in _city_id
exit_after_echo(CITY_NOT_FOUND)
NameError: name 'exit_after_echo' is not defined
wujunze@Mac: ~
$ iquery -m [21:23:52]
Traceback (most recent call last):
File "/anaconda3/bin/iquery", line 11, in <module>
sys.exit(cli())
File "/anaconda3/lib/python3.6/site-packages/iquery/core.py", line 96, in cli
result = query()
File "/anaconda3/lib/python3.6/site-packages/iquery/movies.py", line 99, in query
rows = r.json()['subject_collection_items']
File "/anaconda3/lib/python3.6/site-packages/requests/models.py", line 892, in json
return complexjson.loads(self.text, **kwargs)
File "/anaconda3/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/anaconda3/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/anaconda3/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 5 (char 4)
FAIL
在日本,火车票、演出、电影、歌词都不能用
有的主要是decodeerror, 就我猜测是国外无法访问那些api, 要是代码里能选择是否翻墙就好了
彩票和莆田系医院可以用。
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning) Traceback (most recent call last): File "/usr/local/bin/tickets", line 11, in <module> sys.exit(cli()) File "/usr/local/lib/python2.7/dist-packages/tickets/core.py", line 231, in cli rows = resp.json()['data']['datas'] TypeError: 'int' object has no attribute '__getitem__'
Traceback (most recent call last):
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\runpy.py", l
ine 184, in _run_module_as_main
"main", mod_spec)
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\runpy.py", l
ine 85, in run_code
exec(code, run_globals)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python35-32\Scripts\iquery.e
xe_main.py", line 9, in
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-package
s\iquery\core.py", line 112, in cli
result = query(args.as_train_query_params)
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-package
s\iquery\trains.py", line 250, in query
return TrainTicketsQuery(*params).query()
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-package
s\iquery\trains.py", line 238, in query
rows = r.json()['data']['datas']
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\site-package
s\requests\models.py", line 850, in json
return complexjson.loads(self.text, **kwargs)
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\json_init
_.py", line 319, in loads
return _default_decoder.decode(s)
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\json\decoder
.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users\dell\appdata\local\programs\python\python35-32\lib\json\decoder
.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
环境是win7家庭版 , python3.5 ,cmd命令行下执行 iquery 南昌 任丘 20170126
~ tickets -dt 上海 北京 20160615
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/tickets", line 9, in <module>
load_entry_point('tickets==0.1.7', 'console_scripts', 'tickets')()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
return ep.load()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tickets/core.py", line 34, in <module>
from _compat import to_unicode
ImportError: No module named '_compat'
@thisline 'tickets -h' should be 'iquery -h'?
想问问那个豆瓣的url是怎么抓的,我试着在豆瓣电影上分析了几次network都没发现这个url。。比较好奇……使用抓包软件抓的么?
Collecting tickets
Using cached tickets-0.1.7.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-l11dopr7/tickets/setup.py", line 30, in <module>
long_description=read('README.rst') + '\n\n' + read('CHANGES'),
File "/tmp/pip-build-l11dopr7/tickets/setup.py", line 11, in read
return open(f, encoding='utf-8').read()
File "/usr/lib/python3.5/codecs.py", line 895, in open
file = builtins.open(filename, mode, buffering)
FileNotFoundError: [Errno 2] No such file or directory: 'CHANGES'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-l11dopr7/tickets/
i use powershell.
how can i solve it?
PS C:\Python34\Scripts> tickets 北京 上海 20160701
�[91mFrom station not found.�[0m
Python 3.5.2 和 Python 3.6.0 都试了,都报错:
$ uname -a
Linux localhost.localdomain 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux
$ python -V
Python 3.5.2
$ iquery -d 南京 上海 20170201
Traceback (most recent call last):
File "/home/guyskk/.virtualenvs/py35/bin/iquery", line 11, in <module>
sys.exit(cli())
File "/home/guyskk/.virtualenvs/py35/lib/python3.5/site-packages/iquery/core.py", line 112, in cli
result = query(args.as_train_query_params)
File "/home/guyskk/.virtualenvs/py35/lib/python3.5/site-packages/iquery/trains.py", line 250, in query
return TrainTicketsQuery(*params).query()
File "/home/guyskk/.virtualenvs/py35/lib/python3.5/site-packages/iquery/trains.py", line 238, in query
rows = r.json()['data']['datas']
File "/home/guyskk/.virtualenvs/py35/lib/python3.5/site-packages/requests/models.py", line 850, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
欢迎一起讨论 😄
iquery 北京西 广州南 713
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:732: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
InsecureRequestWarning)
Sorry, server is not responding.
Is this just me?
from .utils import colored, requests_get, exit_after_echo
SystemError: Parent module '' not loaded, cannot perform relative import
Traceback (most recent call last):
File "C:\Python34\lib\runpy.py", line 170, in run_module_as_main
"main", mod_spec)
File "C:\Python34\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Python34\Scripts\tickets.exe__main.py", line 9, in
File "C:\Python34\lib\site-packages\tickets\core.py", line 92, in cli
q.query().pretty_print()
File "C:\Python34\lib\site-packages\tickets\trains.py", line 195, in query
params = self._build_params()
File "C:\Python34\lib\site-packages\tickets\trains.py", line 189, in _build_params
d['from_station'] = self._from_station_telecode
File "C:\Python34\lib\site-packages\tickets\trains.py", line 158, in _from_station_telecode
code = self.stations.get(self.from_station)
File "C:\Python34\lib\site-packages\tickets\trains.py", line 151, in stations
for line in f.readlines():
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 2: illegal multibyte sequence
at last i make it run
https://segmentfault.com/q/1010000002515129/a-1020000002515648
File "C:\Python34\lib\site-packages\tickets\trains.py", line 151, in stations
with open(filepath, 'rb') as f:
源码安装。
python版本:
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
运行命令:
tickets -g 上海 北京 20160624
File "/usr/local/bin/tickets", line 9, in <module>
load_entry_point('tickets==0.2.3', 'console_scripts', 'tickets')()
File "/usr/local/lib/python2.7/site-packages/tickets-0.2.3-py2.7.egg/tickets/core.py", line 92, in cli
q.query().pretty_print()
File "/usr/local/lib/python2.7/site-packages/tickets-0.2.3-py2.7.egg/tickets/trains.py", line 213, in query
params = self._build_params()
File "/usr/local/lib/python2.7/site-packages/tickets-0.2.3-py2.7.egg/tickets/trains.py", line 207, in _build_params
d['from_station'] = self._from_station_telecode
File "/usr/local/lib/python2.7/site-packages/tickets-0.2.3-py2.7.egg/tickets/trains.py", line 158, in _from_station_telecode
code = self.stations.get(self.from_station)
File "/usr/local/lib/python2.7/site-packages/tickets-0.2.3-py2.7.egg/tickets/trains.py", line 150, in stations
with open(filepath, 'r', encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.