본문 바로가기

Python/[Project] 트윗 캡쳐 투 비디오

트윗 캡쳐 후 비디오 만들기 2 - twitter capture module test

안녕하세요. 카이랏입니다.

 

우선 twitter를 캡쳐할 수 있는 기능을 만드려고 합니다.

 

1. Javascript 모듈 테스트

먼저 Javascript로 된 모듈이 있어서 가져와 실행하였으나 잘 되지 않았습니다. 물론 시간이 넉넉해서 왜 실행이 안되는지를 살펴보면 좋겠지만 시간이 한정적이기에 python 모듈이 있다면 더 좋겠다고 생각하였습니다. 그래서 일단 Javascript 모듈은 배제시켰습니다.

 

2. Python 모듈 찾기 - tweepy, tweet-capture

이 후에 검색을 통해서 python 에도 동일한 기능이 있는지를 살펴봤고 트윗을 캡쳐할 수 있는 기능을 구현하기 위한 2가지 모듈을 찾았습니다.

 

첫 번째로 찾는 모듈은 tweepy 입니다. twitter에서 제공하는 API를 wrapping한 모듈이었습니다. 이 모듈을 이용하면 해쉬태그를 통해 twitter를 검색할 수 있습니다.

 

두 번째로는 tweet-capture 입니다. 이는 내부적으로 selenium을 이용하여 트위터의 웹 상에 보여지는 화면을 캡쳐하는 기능을 합니다.

 

따라서 이 두 가지 모듈을 갖고 개발을 진행하면 됩니다.  tweepy 에서 제공하는 검색 기능으로 해쉬태그를 검색하여 해당 twitter의 링크를 갖고 옵니다. 그리고 가져온 링크로 tweet-capture를 이용해 화면을 캡쳐하면 됩니다. 캡쳐된 화면은 이미지 파일로 저장됩니다.

 

3. Twitter 개발자 등록 후 키 발급 문제!

그런데 tweepy 모듈을 수행하던 중 필요한 것이 있었습니다. 바로 twitter 개발자 사이트에서 제공하는 key 들이었습니다.

 
# Set up Twitter API authentication
consumer_key = "YOUR_CONSUMER_KEY"
consumer_secret = "YOUR_CONSUMER_SECRET"
access_token = "YOUR_ACCESS_TOKEN"
access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
 

이 key들이 없이는 twitter에 접근하여 아무 것도 수행할 수 없습니다.

 

하지만 내가 갖고 있는 폰으로는 어떤 확인 문자도 받을 수 없는 상태입니다.

내일은 그래서 통신사에 가서 이를 확인하고 나머지 작업을 진행할 예정입니다.


Hello. This is Kairat.

 

First of all, I'm trying to create a function that can capture twitter.

 

1. Javascript module tests

First, there was a Javascript module, so I imported it and ran it, but it didn't work. Of course, it would be nice to have plenty of time to look into why it doesn't run, but since time is limited, I thought it would be better if there was a python module. So, I excluded the Javascript module for now.

 

2. Finding Python modules - tweepy, tweet-capture

I searched to see if python had the same function, and to implement the function to capture tweets, Found 2 modules.

 

The first module to look for is  tweepy< span> . It was a module that wrapped the API provided by twitter. This module allows you to search twitter through hashtags.

 

secondly tweet-capture< span> . This internally uses selenium to capture the screen displayed on Twitter's web.

 

So you can develop with these two modules. Provided by tweepy Search for hashtags with the search function to get the link of the corresponding twitter. Then you can capture the screen using tweet-capture with the imported link. The captured screen is saved as an image file.

 

3. Issue with issuing keys after registering as a Twitter developer!

But while running the tweepy module, there was something I needed. These were the keys provided by the twitter developer site.

 
# Set up Twitter API authentication
consumer_key = "YOUR_CONSUMER_KEY"
consumer_secret = "YOUR_CONSUMER_SECRET"
access_token = "YOUR_ACCESS_TOKEN"
access_token_secret = "YOUR_ACCESS_TOKEN_SECRET"
 

You cannot access twitter and do anything without these keys.

 

But I can't receive any confirmation text on my phone.

Tomorrow, so I'm going to go to the carrier to check it out and do the rest.