2016-06-14 6 views
2

今、私は選択されたtwitchチャンネルのスクリーンショットを撮り、それらのスクリーンショットを修正してGUIに載せることになっているPythonプロジェクトを開始します。 GUIは問題ではありませんが、スクリーンショットに問題があります。
私はtwitchコミュニケーションに対処する2つのリソース、python-twitchパッケージとttvsnap(https://github.com/chfoo/ttvsnap)というスクリプトを見つけました。
スクリーンショットに関連するものは何も見つかりませんでしたので、このパッケージは私にとって助けになりませんでした。スクリプトは有望に見えましたが、いくつかの問題が発生しました。PythonでTwitchからスクリーンショットを取得

作成者によれば、ttvsnapは定期的にツイッチストリームのスクリーンショットを取り出し、選択したディレクトリに配置します。
私はスクリプトを起動しようとすると、私はこのエラーを取得しています:スクリプトから

Traceback (most recent call last): 
    File "ttvsnap.py", line 13, in <module> 
     import requests 
ImportError: No module named 'requests' 

消去「インポート要求」、私はそれを実行することができますが、スクリプトは、選択に問題がありますディレクトリ。クリエイターから

Python ttvsnap.py 'streamname here' 'directory here' 

例のディレクトリは「./screenshot/」でしたが、その入力で、私は(私は「多分ので、次のエラーを取得しています:スクリプトを実行するには、私が書くことになっていますWindows上メートル):?Cのようなディレクトリをしようと

Output directory specified is not valid. 

:\ DevFiles \のスクリーンショットは私に次のエラーを与える:

Invalid drive specification. ###Translated this line since I'm using a German OS 
Traceback (most recent call last): 
    File "ttvsnap.py", line 176, in <module> 
    main() 
    File "ttvsnap.py", line 46, in main 
    subprocess.check_call(['convert', '-version']) 
    File "C:\Program Files (x86)\Python35-32\lib\subprocess.py", line 584, in check_call 
    raise CalledProcessError(retcode, cmd) 
subprocess.CalledProcessError: Command '['convert', '-version']' returned non-zero exit status 4 

それが実行するために取得する方法上の任意のアイデアや異なるリソースを使用は非常に高く評価されるだろう。

+1

あなたは 'ピップrequests'をインストールしようとしたことがありますか?これは標準ライブラリの一部ではありません。 – jonrsharpe

答えて

0

セレンは、サイトをナビゲートしてスクリーンショットを撮るのに便利です。

http://selenium-python.readthedocs.io/

はあなたが必要とする何をすべき例を肉付け。同様 要点リンク: https://gist.github.com/ryantownshend/6449c4d78793f015f3adda22a46f1a19

""" 
basic example. 

Dirt simple example of using selenium to screenshot a site. 

Defaults to using local Firefox install. 
Can be setup to use PhantomJS 

http://phantomjs.org/download.html 

This example will run in both python 2 and 3 
""" 
import os 
from selenium import webdriver 
from selenium.webdriver.common.by import By 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.support.ui import WebDriverWait 


def main(): 
    """the main function.""" 
    driver = webdriver.Firefox() 
    # driver = webdriver.PhantomJS() 
    driver.get("http://google.com") 
    # assert "Python" in driver.title 
    elem = driver.find_element_by_name("q") 
    elem.clear() 
    elem.send_keys("cats") 
    elem.send_keys(Keys.RETURN) 

    # give the query result time to load 
    WebDriverWait(driver, 10).until(
     EC.visibility_of_element_located((By.ID, "resultStats")) 
    ) 

    # take the screenshot 
    pwd = os.path.dirname(os.path.realpath(__file__)) 
    driver.save_screenshot(os.path.join(pwd, 'cats.png')) 
    driver.close() 

if __name__ == '__main__': 
    main() 
+0

私の目的のために、ImageMagickのようなセレンの必要条件はありますか?一度パッケージをインストールするといいですか? – Hillburn

+0

あなたのための例で、投稿を更新しました。 –

+0

ありがとう、この例は私のためにPhantomJSで動作します。しかし、私はPythonの初心者ですので、スクリーンショットの宛先をどのように設定するかは十分に理解できていません。 "__ file __"変数は、スクリプト自体を含むファイルを参照していますか? – Hillburn

1

使用しようとしているオープンソースプロジェクトから物を削除しないでください。

あなたはそれに問題がある場合は代わりに、不足しているパッケージをインストールし、

pip install requestsは、多分あなたはpipを持っていないので、それをインストールします。

またはpython.exe -m pip install requestsを使用してください。


このエラーOutput directory specified is not valid.は、このラインによるものです:

if not os.path.isdir(args.output_dir): 
    sys.exit('Output directory specified is not valid.') 

それは一般的にディレクトリが存在しないことを意味します。

Invalid drive specification. ###Translated this line since I'm using a German OS 
Traceback (most recent call last): 
    File "ttvsnap.py", line 176, in <module> 
    main() 
    File "ttvsnap.py", line 46, in main 
    subprocess.check_call(['convert', '-version']) 
    File "C:\Program Files (x86)\Python35-32\lib\subprocess.py", line 584, in check_call 
    raise CalledProcessError(retcode, cmd) 
subprocess.CalledProcessError: Command '['convert', '-version']' returned non-zero exit status 4 

それはちょうどあなたがImagemagickがインストールされていないことを意味します


は、最後のエラーについては、それがコマンドconvertを実行することはできません。あなたはここにあなたのアーキテクチャ用右のインストーラをダウンロードしてインストールすることができます:http://www.imagemagick.org/script/binary-releases.php

次にチェックが入っこれらのオプションでそれをインストールします。 enter image description here

次に試してみて、convertコマンドは端末から実行していることを確認します。そうでない場合は、次の指示に従ってください。

Lastly you have to set MAGICK_HOME environment variable to the path of ImageMagick (e.g. C:\Program Files\ImageMagick-6.7.7-Q16). You can set it in Computer ‣ Properties ‣ Advanced system settings ‣ Advanced ‣ Environment Variables....

source

+0

インストールされたリクエスト。スクリプトからこれ以上消去する必要はありませんが、以前と同じエラーメッセージが表示されています。 – Hillburn

+0

@Hillburnは問題のフォルダを作成しましたか?それは現在存在しますか? – majidarif

+0

@Hillburn 'python3 ttvsnap.py verycoolstreamer/screenshots /'を試してくださいが、 'screenshots'ディレクトリがスクリプトを実行しているカレントディレクトリに存在することを確認してください。 – majidarif

関連する問題