2

「shodan」APIを使いたいのですが、うまくいきませんでした。

最初に私はターミナルeasy_install shodan でこのコマンドを実行しました、そしてこれが出力です:

$easy_install shodan
Searching for shodan
Best match: shodan 0.8.1
Processing shodan-0.8.1-py2.7.egg
shodan 0.8.1 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/shodan-0.8.1-py2.7.egg
Processing dependencies for shodan
Finished processing dependencies for shodan

それから私は自分のコードを書きました:

#! /usr/bin/python en

    from shodan import WebAPI

    SHODAN_API_KEY = "Key"

    api = WebAPI(SHODAN_API_KEY)


    # Wrap the request in a try/ except block to catch errors

それは私にエラーを与えました:

ImportError: cannot import name WebAPI

私は同様の問題を検索しました。いくつかの答えはファイル名の変更であり、いくつかはpycファイルの削除でした。両方の答えを試しましたが、うまくいきません。

4

2 に答える 2

3

スクリプトの名前は何ですか?スクリプトの名前が「shodan」、つまりShodanライブラリと同じ名前の場合、名前の衝突が発生する可能性があります。Python 3にも問題があり、インポートの問題が発生しましたが、Shodan APIライブラリの最新バージョンを使用している場合は、解決する必要があります。そして、インデントが間違っているように見えるというlucのコメントをエコーし​​ます。したがって、スクリプトを実行するには、それも修正する必要があります。

于 2013-02-13T18:04:38.583 に答える
0

pycryptoをインストールする必要があるという答えを見つけました

sudo apt-get install python-crypto

于 2014-01-12T14:38:12.587 に答える