Computer >> Máy Tính >  >> Lập trình >> Python

Rainbow Stream - Ứng dụng Twitter dòng lệnh nâng cao dành cho Linux

Suối cầu vồng là một Twitter-người dùng miễn phí và mã nguồn mở cho dòng lệnh Linux, được phát hành theo Giấy phép MIT. Nó có khả năng hiển thị luồng tweet Rea ltime, soạn tweet, tìm kiếm, yêu thích, v.v. Nó được viết bằng Python và được xây dựng dựa trên Twitter API Công cụ Twitter Python . Để chạy ứng dụng này trong bảng điều khiển của bạn, bạn phải cài đặt python pip phiên bản 2.7.x hoặc 3.x .

Tính năng

  • Đây là một twitter-client mã nguồn mở và miễn phí cho dòng lệnh Linux.

  • Nó có khả năng hiển thị hình ảnh twitter trong Terminal.

  • Nó hỗ trợ Proxy.

  • Nó hỗ trợ chế độ tương tác.

  • Tùy chỉnh chủ đề được triển khai.

  • Nó có khả năng hiển thị luồng twitter theo thời gian thực.

  • Bạn có thể tweet, tìm kiếm, tweet yêu thích ngay từ thiết bị đầu cuối của mình.

Cài đặt ứng dụng Twitter Rainbow Stream trong Linux

Trước khi cài đặt luồng Rainbow, bạn phải kiểm tra phiên bản Python xem nó đã được cài đặt hay chưa bằng cách sử dụng lệnh sau -

$ python --version

Đầu ra mẫu phải như thế này -

Python 2.7.11+

Để cài đặt gói python-pip, hãy sử dụng lệnh sau -

$ sudo apt-get install python-pip

Đầu ra mẫu phải như thế này -

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libexpat1-dev libpython-all-dev libpython-dev libpython2.7-dev python-all python-all-dev python-dev python-pip-whl python-pkg-resources
python-setuptools python-wheel python2.7-dev
Suggested packages:
python-setuptools-doc
The following NEW packages will be installed:
libexpat1-dev libpython-all-dev libpython-dev libpython2.7-dev python-all python-all-dev python-dev python-pip python-pip-whl
python-pkg-resources python-setuptools python-wheel python2.7-dev
0 upgraded, 13 newly installed, 0 to remove and 21 not upgraded.
Need to get 29.7 MB of archives.
After this operation, 45.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 libexpat1-dev amd64 2.1.0-7 [115 kB]
Get:2 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpython2.7-dev amd64 2.7.11-7ubuntu1 [27.8 MB]
Get:3 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpython-dev amd64 2.7.11-1 [7,728 B]
Get:4 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpython-all-dev amd64 2.7.11-1 [992 B]
Get:5 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-all amd64 2.7.11-1 [978 B]
Get:6 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python2.7-dev amd64 2.7.11-7ubuntu1 [280 kB]
Get:7 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-dev amd64 2.7.11-1 [1,160 B]
Get:8 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-all-dev amd64 2.7.11-1 [1,000 B]
Get:9 https://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python-pip-whl all 8.1.1-2 [1,074 kB]
Get:10 https://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python-pip all 8.1.1-2 [144 kB]
Get:11 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-pkg-resources all 20.7.0-1 [108 kB]
Get:12 https://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-setuptools all 20.7.0-1 [169 kB]
Get:13 https://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python-wheel all 0.29.0-1 [48.0 kB]
Fetched 29.7 MB in 19s (1,494 kB/s)
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 178346 files and directories currently installed.)
Preparing to unpack .../libexpat1-dev_2.1.0-7_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-7) ...
Selecting previously unselected package libpython2.7-dev:amd64.
Preparing to unpack .../libpython2.7-dev_2.7.11-7ubuntu1_amd64.deb ...
.........................................................................

Để kiểm tra phiên bản pip đã cài đặt , sử dụng lệnh sau -

$ pip --version

Đầu ra mẫu phải như thế này -

pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

Để cài đặt ứng dụng twitter stream cầu vồng, hãy sử dụng lệnh sau -

# pip install rainbowstream [For Python 2.7.x version]
# pip3 install rainbowstream[For Python 3.x version]

Đầu ra mẫu phải như thế này -

Collecting rainbowstream
Downloading rainbowstream-1.3.3.tar.gz (46kB)
100% |████████████████████████████████| 51kB 619kB/s
Collecting python-dateutil (from rainbowstream)
Downloading python_dateutil-2.5.3-py2.py3-none-any.whl (201kB)
100% |████████████████████████████████| 204kB 4.0MB/s
Collecting arrow (from rainbowstream)
Downloading arrow-0.7.0.tar.gz (75kB)
100% |████████████████████████████████| 81kB 7.9MB/s
Collecting requests==2.5.3 (from rainbowstream)
Downloading requests-2.5.3-py2.py3-none-any.whl (468kB)
100% |████████████████████████████████| 471kB 2.6MB/s
Collecting pyfiglet (from rainbowstream)
Downloading pyfiglet-0.7.5.tar.gz (767kB)
100% |████████████████████████████████| 768kB 716kB/s
Collecting twitter (from rainbowstream)
Downloading twitter-1.17.1-py2.py3-none-any.whl (55kB)
100% |████████████████████████████████| 61kB 6.7MB/s
Collecting Pillow (from rainbowstream)
Downloading Pillow-3.2.0.zip (10.5MB)
100% |████████████████████████████████| 10.5MB 125kB/s
Collecting PySocks (from rainbowstream)
Downloading PySocks-1.5.6.tar.gz
Collecting six>=1.5 (from python-dateutil->rainbowstream)
Downloading six-1.10.0-py2.py3-none-any.whl
Building wheels for collected packages: rainbowstream, arrow, pyfiglet, Pillow, PySocks
Running setup.py bdist_wheel for rainbowstream ... done
Stored in directory: /home/linux/.cache/pip/wheels/ce/a6/ee/78d894d77cee1169cf0db3a9a60705fc28ddf6880cae21cd28
Running setup.py bdist_wheel for arrow ... done
Stored in directory: /home/linux/.cache/pip/wheels/39/9d/23/0e26a93dad0f99c2c6cc22728222ec243fc5a11313c547e98d
Running setup.py bdist_wheel for pyfiglet ... done
Stored in directory: /home/linux/.cache/pip/wheels/22/64/50/061d962f0938800687c7d965aec42c3c3b5344634f2242f3d8
Running setup.py bdist_wheel for Pillow ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-HnxB6G/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpRiN63bpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/PIL
copying PIL/PaletteFile.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/ImageDraw.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/FontFile.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/_binary.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/JpegPresets.py -> build/lib.linux-x86_64-2.7/PIL
copying PIL/PyAccess.py -> build/lib.linux-x86_64-2.7/PIL
....................................................................

Để nhận trợ giúp về Rainbowstream, hãy sử dụng lệnh sau -

$ rainbowstream -h

Đầu ra mẫu phải như thế này -

usage: rainbowstream [-h] [-s STREAM] [-to TIMEOUT] [-tt TRACK_KEYWORDS]
[-fil FILTER] [-ig IGNORE] [-iot] [-24] [-ph PROXY_HOST]
[-pp PROXY_PORT] [-pt PROXY_TYPE]

optional arguments:
-h, --help show this help message and exit
-s STREAM, --stream STREAM
Default stream after program start. (Default: mine)
-to TIMEOUT, --timeout TIMEOUT
Timeout for the stream (seconds).
-tt TRACK_KEYWORDS, --track-keywords TRACK_KEYWORDS
Search the stream for specific text.
-fil FILTER, --filter FILTER
Filter specific screen_name.
-ig IGNORE, --ignore IGNORE
Ignore specific screen_name.
-iot, --image-on-term
Display all image on terminal.
-24, --color-24bit Display images using 24bit color codes.
-ph PROXY_HOST, --proxy-host PROXY_HOST
Use HTTP/SOCKS proxy for network connections.
-pp PROXY_PORT, --proxy-port PROXY_PORT
HTTP/SOCKS proxy port (Default: 8080).
-pt PROXY_TYPE, --proxy-type PROXY_TYPE
Proxy type (HTTP, SOCKS4, SOCKS5; Default: SOCKS5).

Rainbow Stream Twitter Client Sử dụng

Để sử dụng ứng dụng khách twitter dòng Rainbow, hãy sử dụng lệnh sau -

$ rainbowstream

Khi bạn nhập lệnh trên, nó sẽ mở ra một màn hình như hình dưới đây -

Rainbow Stream - Ứng dụng Twitter dòng lệnh nâng cao dành cho Linux

Đăng nhập bằng thông tin đăng nhập của bạn và bạn sẽ nhận được một mã pin. Nếu bạn đã đăng nhập vào tài khoản của mình, trang sẽ hiển thị mã PIN.

Rainbow Stream - Ứng dụng Twitter dòng lệnh nâng cao dành cho Linux

Sao chép mã PIN từ Trình duyệt web yêu thích HTTP vào thiết bị đầu cuối của bạn và nhấn phím quay lại như được hiển thị bên dưới -

You are running latest version (1.3.3)
Hi there! We're gonna get you all set up to use Rainbow Stream.
In the web browser window that opens please choose to Allow
access. Copy the PIN number that appears on the next page and paste or
type it here:
Opening: https://api.twitter.com/oauth/authorize?oauth_token=AB-78QAAAAAAXZ0wAAABVGBoQvQ

Please enter the PIN: *******

That's it! Your authorization keys have been written to /root/.rainbow_oauth.
_ _ _ _ _ ___________ _____
| | (_) | | | | ||___ / _ || _ |
| | ___| |_| |_ _ _ _ __ _ __ __ _ ___ __ _ __| | / /| |/' || |/' |
| |/ / | __| __| | | | '_ \| '__/ _` / __|/ _` |/ _` | / / | /| || /| |
| <| | |_| |_| |_| | |_) | | | (_| \__ \ (_| | (_| |./ / \ |_/ /\ |_/ /
|_|\_\_|\__|\__|\__,_| .__/|_| \__,_|___/\__,_|\__,_|\_/ \___/ \___/
| |
|_|

Need tips ? Type "h" and hit Enter key!

bạn sẽ nhận được các tweet như được hiển thị bên dưới -

[@kittuprasad700]:
Girish Johar @girishjohar 2016/04/29 10:44:34
₪:0 ♥:0 id:0 via Twitter for Android
Right time finally ... Wishing you a Very Happy Birthday @shiekhspear 😁😁👏👍
Zoom TV @ZoomTV 2016/04/29 10:45:03
₪:0 ♥:0 id:1 via TweetDeck
.@BeingSalmanKhan will bring visibility to Rio Olympics says @SGanguly99 https://t.co/cfG0KnxJqW

Rajdeep Sardesai @sardesairajdeep 2016/04/29 10:45:19
₪:0 ♥:0 id:2 via Twitter for iPhone
Not a single minute of LS spent discussing the drought! https://scroll.in/article/807324/this-chart-shows-how-much-time-the-lok-sabha-has-spent-discussing-the-horrific-drought-none

El Androide Libre @elandroidelibre 2016/04/29 10:45:37
₪:0 ♥:0 id:3 via Buffer
Rick Osterloh regresa a trabajar en Google https://bit.ly/1rlKVed https://t.co/BmlMykUSmd

Để hiển thị xu hướng, hãy sử dụng lệnh sau -

[twittername]: treand

Đầu ra mẫu phải như thế này -

WIRED @WIRED 2016/04/29 10:47:05
₪:0 ♥:0 id:4 via SocialFlow
This is the app you need to wrangle your millions of messengers https://bit.ly/1SU6Rcx

Để lấy danh sách những người theo dõi, hãy sử dụng lệnh sau-

[twittername]: ls fl

Để nhận trợ giúp, hãy sử dụng lệnh sau -

[twittername]: h

Đầu ra mẫu phải như thế này -

Hi boss! I'm ready to serve you right now!
-----------------------------------------------------------------------------
You are already on your personal stream.
Any update from Twitter will show up immediately.
In addition, following commands are available right now:

♪ Twitter help
   h discover will show help for discover commands.
   h tweets will show help for tweets commands.
   h messages will show help for messages commands.
   h friends_and_followers will show help for friends and followers commands.
   h list will show help for list commands.
   h stream will show help for stream commands.

♪ Smart shell
   111111 * 9 / 7 or any math expression will be evaluate by Python interpreter.
   Even cal will show the calendar for current month.

♪ Config
   theme will list available theme. theme monokai will apply monokai theme immediately.
   config will list all config.
      config ASCII_ART will output current value of ASCII_ART config key.
      config TREND_MAX default will output default value of TREND_MAX config key.
      config CUSTOM_CONFIG drop will drop CUSTOM_CONFIG config key.
      config IMAGE_ON_TERM = true will set value of IMAGE_ON_TERM config key to True.

♪ Screening
   h will show this help again.
   p will pause the stream.
   r will unpause the stream.
   c will clear the screen.
   v will show version info.
   q will quit.

-----------------------------------------------------------------------------
Have fun and hang tight!

Để thoát khỏi Rainbow Stream, hãy sử dụng lệnh sau -

[twittername]: q

Đầu ra mẫu phải như thế này -

See you next time :)

Sau bài viết này, bạn sẽ có thể hiểu - “Cách cài đặt Rainbow Stream và cách sử dụng Rainbow Stream trong Ubuntu”. Trong các bài viết tiếp theo của chúng tôi, chúng tôi sẽ đưa ra nhiều thủ thuật và mẹo dựa trên Linux. Hãy tiếp tục đọc!