Skip to main content

Python SDK

Project description

TeyeSpider SDK for Python

The SDK for Python contains two parts:

  1. CLI Tool
  2. Utility Tools

Installation Prerequisite

You should install the requirement below before installing the teyespider-sdk.

Click==7.0
requests==2.22.0
prettytable==0.7.2
scrapy==2.2.0
pymongo==3.10.1
pymysql==0.9.3
psycopg2-binary==2.8.5
kafka-python==2.0.1
elasticsearch==7.8.0
pathspec==0.8.0

CLI Tool

The CLI Tool is mainly designed for those who are more comfortable using command line tools to interact with teye-spider.

The installation of the CLI Tool is simple:

pip install teyespider-sdk

Then, you can use the teye-spider command in the command prompt to action with teye-spider.

Check the help document below, or you can refer to the official documentation (Chinese).

teye-spider --help

Usage

# Hello to teye-spider
teye-spider hello
# Login on first time
teye-spider login -u admin -a  http://xxx-master.xxxxx.10.92.xx.xx.nip.io:xxx/api
# Upload spider to platform
teye-spider upload -N demo -d ~/Downloads/tutorial/ -n demo -c res_demo
# explore other command
teye-spider --help

Utility Tools

Utility tools mainly provide some helper methods to make it easier for you to integrate your spiders into teye-spider, e.g. saving results.

Below are integration methods of Scrapy and general Python spiders with teye-spider.

⚠️Note: make sure you have already installed teye-spider-sdk using pip.

Scrapy Integration

In settings.py in your Scrapy project, find the variable named ITEM_PIPELINES (a dict variable). Add content below.

ITEM_PIPELINES = {
    'teyespider.pipelines.teye-spiderMongoPipeline': 888,
}

Then, start the Scrapy spider. After it's done, you should be able to see scraped results in Task Detail -> Result

General Python Spider Integration

Please add below content to your spider files to save results.

# import result saving method
from teyespider import save_item

# forexample,it your result is:
result = {'name': 'teyespider'}

# call result saving method
save_item(result)

Then, start the spider. After it's done, you should be able to see scraped results in Task Detail -> Result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teyespider-sdk-0.0.3.tar.gz (12.6 kB view details)

Uploaded Source

File details

Details for the file teyespider-sdk-0.0.3.tar.gz.

File metadata

  • Download URL: teyespider-sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.10

File hashes

Hashes for teyespider-sdk-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cb08cbdeba719333aa8e33dfa6774da86191d049bc9f2b0c608fc0be782aafa3
MD5 a601af8f02a39b0316f0da6e15dd919e
BLAKE2b-256 fce9ffc0d24ce709015eb718b5fe19c6da419ef06b0b26423401b398282937ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page