การสกัดทวีต
Mar 29 2023
การใช้ Tweepy สำหรับการขุดข้อมูล-1
Tweepy เป็นแพ็คเกจ Python ที่ทำงานด้วยการใช้ Twitter API แต่ในการขุดข้อมูลจาก Twitter คุณต้องมีบัญชีของนักพัฒนา Twitter เพื่อทำงานกับทั้ง API และแพ็คเกจ Tweepy
Tweepy เป็นแพ็คเกจ Python ที่ทำงานด้วยการใช้ Twitter API แต่ในการขุดข้อมูลจาก Twitter คุณต้องมีบัญชีของนักพัฒนา Twitter เพื่อทำงานกับทั้ง API และแพ็คเกจ Tweepy
ก่อนที่เรา จะเริ่ม โปรดติดตามบล็อกนี้โดยJean Christophe Chouinardเกี่ยวกับวิธีสร้างบัญชีนักพัฒนา Twitter บนTwitter API
หลังจากดำเนินการข้างต้นแล้ว กรุณาติดตั้ง Tweepy โดยใช้:
pip install tweepy
กำลังโหลดไลบรารีที่จำเป็น
import pandas as pd
import seaborn as sns
import warnings
warnings.filterwarnings("ignore")
import tweepy
เก็บคีย์การรับรองความถูกต้องของคุณไว้เป็นความลับและไม่แบ่งปันกับใคร
with open('../auth/auth_keys.txt') as f:
lines = [line.rstrip() for line in f]
Consumer_Key = lines[0]
Consumer_Secret = lines[1]
Bearer_Token = lines[2]
Access_Token = lines[3]
Access_Secret = lines[4]
การรับรองความถูกต้องและการตรวจสอบ
# Authenticate with Twitter OAuth 1.0a User Context
auth = tweepy.OAuth1UserHandler(
Consumer_Key,Consumer_Secret,Access_Token,Access_Secret
)
api = tweepy.API(auth)
print(api.verify_credentials().screen_name) # Verified





































![รายการที่เชื่อมโยงคืออะไร? [ส่วนที่ 1]](https://post.nghiatu.com/assets/images/m/max/724/1*Xokk6XOjWyIGCBujkJsCzQ.jpeg)