Cov txheej txheem:
- Kauj ruam 1: Nkag mus thiab Tsim Tus Kheej Tus Kheej
- Kauj ruam 2: Tsim App
- Kauj ruam 3: App Screen
- Kauj Ruam 4: Ua RedditBot Folder thiab Qhib CMD
- Kauj Ruam 5: Pip Install PRAW
- Kauj Ruam 6: Luag Praw.ini Cov Ntaub Ntawv rau hauv Folder
- Kauj Ruam 7: Ua Cov Ntaub Ntawv Python Tshiab
- Kauj Ruam 8: Muab tshuaj txhuam cov Code
- Kauj ruam 9: Khiav Koj Cov Cai
- Kauj ruam 10: Thiab Qhov ntawd yog nws
Video: Reddit Teb Bot: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Lub hom phiaj ntawm phau ntawv qhia no yog tsim kom yooj yim Reddit bot. Reddit bot yog qhov program uas txheeb xyuas cov ntawv/lus pom ntawm Reddit, thiab tuaj yeem ua rau cov ntaub ntawv nws khaws. Qhov no tuaj yeem yog qhov tseem ceeb rau ntau qhov laj thawj, zoo li tau paub nrog Reddit API (Application Programming Interface) siv PRAW lossis kom teb tau yooj yim rau ntau cov ntawv ib zaug. Txhawm rau txhawm rau sib tw qhov no, koj yuav tsum muaj tus lej Reddit, yuav tsum muaj qee qhov kev paub nrog coding hauv Python thiab xav kom muaj koj li kab ke system PATH sib txawv rau Python teeb tsa kom koj tuaj yeem sau Python ntawm kab hais kom ua lossis davhlau ya nyob twg. Yog tias tsis muaj qhov ua rau koj nkag siab, tej zaum koj tsis tau npaj rau qhov kev qhia no. Yog tias cov kauj ruam no tau ua tiav, qhov no yuav tsum ua tiav tsis pub dhau 30 feeb. Hmoov zoo thiab kuv vam tias koj pom cov ntaub ntawv no, zoo siab botting!
Kauj ruam 1: Nkag mus thiab Tsim Tus Kheej Tus Kheej
Thawj zaug nkag mus rau Reddit lossis ua tus account thiab mus rau https://ssl.reddit.com/prefs/apps/ los tsim tus kheej app.
Kauj ruam 2: Tsim App
Lub npe app thiab ua kom ntseeg tau tias cov kab ntawv tau sau, tseem ntxiv lub npe thiab cov lus piav qhia rau app (tuaj yeem yog txhua yam), koj tuaj yeem siv qhov url tsis raug rau qhov hloov pauv url xws li https:// localhost:
Kauj ruam 3: App Screen
Thaum koj tau tsim lub app, koj tau muab 'tsab ntawv siv tus kheej' thiab 'zais cia', xyuas kom koj nco qab tias cov ntawd yog dab tsi, tseem ceeb heev.
Kauj Ruam 4: Ua RedditBot Folder thiab Qhib CMD
Tsim daim nplaub tshev tshiab ntawm koj lub desktop hu ua, "RedditBot" thiab qhib cmd lossis davhlau ya nyob twg. Tom qab ntawd, mus rau nws phau ntawv teev npe siv cd/Users/Admin/Desktop/RedditBot. Kuj tseem nco ntsoov hloov Admin nrog koj tus lej siv.
Kauj Ruam 5: Pip Install PRAW
Tom qab ntawd, ntaus cov lus txib sej -m pip install praw, hla yog tias koj twb tau teeb tsa.
Kauj Ruam 6: Luag Praw.ini Cov Ntaub Ntawv rau hauv Folder
Thaum koj ua tiav qhov ntawd, mus rau qhov chaw koj tau nruab Python thiab ntaus hauv finder praw.ini, coj cov ntawv ntawd thiab rub nws mus rau hauv koj li RedditBot nplaub tshev. Feem ntau yuav Python yuav raug teeb tsa hauv Cov Neeg Siv thiab AppData hauv C tsav.
Kauj Ruam 7: Ua Cov Ntaub Ntawv Python Tshiab
Qhib Python IDLE lossis cov ntawv nyeem sib npaug thiab tsim cov ntawv tshiab hu ua reddit_bot.py. Nco ntsoov khaws nws hauv koj phau ntawv RedditBot uas koj tau ua hauv qib 4.
Kauj Ruam 8: Muab tshuaj txhuam cov Code
Tom qab koj tsim cov ntawv ntawd, muab tshuaj txhuam cov cai no hloov me me. Hloov cov npe neeg siv thiab tus lej nkag mus rau koj tus kheej, tus neeg siv khoom siv tuaj yeem yog ib qho twg, tus neeg siv khoom siv yog koj tus kheej siv tsab ntawv los ntawm kauj ruam 3, thiab tus neeg siv khoom ntiag tug yog koj li kev zais ntawm kauj ruam 3. Tsis tas li ntawd, thaum muab cov lej no ua kom ntseeg tau tias qhov kev nkag mus zoo ib yam daim duab saum toj no. Kuj xyuas kom tseeb tias txhua qhov sib txawv koj nkag mus yog nyob hauv cov lus hais tawm.
#!/usr/bin/python import praw
#Nkag mus rau koj cov ntaub ntawv Reddit raug rau hauv qhov sib txawv hauv qab no
userAgent = 'Sau lub npe Bot'
cID = 'Sau koj tsab ntawv siv tus kheej'
cSC = 'Nkag mus rau koj cov neeg siv khoom zais'
userN = 'Sau koj lub npe siv Reddit'
userP = 'Sau koj tus password Reddit'
numFound = 0
reddit = praw. Reddit (user_agent = userAgent, client_id = cID, client_secret = cSC, username = userN, password = userP)
subreddit = reddit.subreddit ('huab cua') #txhua subreddit koj xav saib xyuas
bot_phrase = 'Aw shucks, zoo li kuv nyob hauv>:(' #phrase uas bot teb nrog
keywords = {'Mob khaub thuas', 'chicago', 'ncov qaumteb', 'vortex'} #muaj txheej cov ntsiab lus los nrhiav hauv subreddits
rau kev xa hauv subreddit.hot (txwv = 10): #this saib saum 10 cov lus tshaj tawm hauv qhov subbreddit
n_title = submission.title.lower () #Make cov npe kab ntawv me me yog li peb tuaj yeem sib piv peb cov ntsiab lus nrog nws.
rau kuv hauv cov ntsiab lus: #dhau los ntawm peb cov ntsiab lus
yog tias kuv nyob hauv n_title: #if ib ntawm peb cov ntsiab lus sib xws lub npe nyob rau sab saum toj 10 ntawm subreddit
numFound = numFound + 1
print ('Bot teb rau:') #teb thiab xa tawm mus rau kab hais kom ua
print ("Title:", xa tawm.title)
print ("Cov ntawv:", submission.selftext)
print ("Cov qhab nia:", xa tawm.score)
luam tawm ("---------------------------------")
print ('Bot hais tias:', bot_phrase)
luam tawm ()
xa tawm.reply (bot_phrase)
Yog hais tias numFound == 0:
luam tawm ()
print ("Thov txim, tsis pom muaj cov lus tshaj tawm nrog cov lus tseem ceeb, sim dua!")
Kauj ruam 9: Khiav Koj Cov Cai
Tom qab ntawd khaws cov ntawv hauv koj phau ntawv RedditBot thiab khiav nws ntawm cmd nrog pythonreddit_bot.py
Kauj ruam 10: Thiab Qhov ntawd yog nws
Tam sim no koj yuav tsum muaj Reddit bot ua haujlwm, muaj peev xwm txheeb xyuas los ntawm koj cov subreddit nyiam thiab teb tau nrog cov kab lus xav tau. Koj kuj tseem tuaj yeem siv tus lej no ua qhov pib zoo rau lwm qhov Reddit bot cov tswv yim, uas tuaj yeem yog ib yam dab tsi los ntawm kev hloov pauv kub, los teb rau cov tib neeg nrog cov duab miv. Ua tsaug rau kev nyeem dhau, vam tias qhov no muaj txiaj ntsig thiab hmoov zoo rau txhua txoj haujlwm yav tom ntej.
Pom zoo:
Yuav Ua Li Cas Hloov Tus Servo Kom Tau Kaw Cov Lus Teb: 7 Cov Kauj Ruam
Yuav Hloov Tus Servo Li Cas Kom Kaw Lub Luag Tawm Tswv Yim: ► Thaum tsav tsheb servo nrog lub microcontroller (raws li Arduino), koj tsuas tuaj yeem muab nws xaj ntawm qhov chaw nyob (hauv PPM teeb liab). Nrog rau qhov kev txiav txim no, servo yuav txav mus rau lub hom phiaj no qhov chaw. Tab sis nws tsis yog tam sim! Koj tsis paub meej thaum twg lo
Yuav Ua Li Cas Tsim Lub Ntiaj Teb Ntse Hauv Ntiaj Teb hauv 10 Hnub: 12 Kauj Ruam
Yuav Tsim Li Cas Lub Ntiaj Teb Ntse Hauv Ntiaj Teb hauv 10 Hnub: Kuv tab tom ua haujlwm uas coj cov tub ntxhais kawm los ntawm Tuam Tshoj, Philippines thiab Asmeskas ua ke ntawm pab pawg los sib tw hauv World Robot Olympiad hauv Long Beach, California. Lub ntsiab lus ntawm xyoo no yog Lub Nroog Ntse. Yog li peb tab tom tsim Lub Nroog Ntse los ntawm Ju
Thoob Ntiaj Teb (Ntiaj Teb Ntse): 5 Kauj Ruam
Nyob ib ncig ntawm lub Ntiaj Teb (Smart Globe): Txoj haujlwm no tau tsim rau chav kawm MIT, Qhia Ua (15.351). Peb txoj haujlwm, hu ua "Thoob Ntiaj Teb", yog lub ntiaj teb ntse uas teb rau cov neeg siv nkag mus hauv ib lub nroog mus rau hauv lub davhlau ya nyob twg. Thaum lub nroog nkag mus, lub ntiaj teb tig ntawm lub cav txuas rau kuv
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej
DIY Teb Teb (TfCD): 12 Kauj Ruam (nrog Duab)
DIY Rotary Garden (TfCD): Nyob Zoo! Peb muab tso ua ke me ntsis qhia yuav ua li cas ua koj tus kheej me me ntawm lub vaj teb, uas hauv peb lub tswv yim tuaj yeem sawv cev rau kev ua vaj tom ntej. Siv qhov txo qis hluav taws xob thiab qhov chaw, cov thev naus laus zis no haum rau nrawm