Bi xêr hatî, Mêvan!

Ji bo gihîştina naveroka forûmê û hemî karûbarên me, divê hûn xwe tomar bikin an têkevin forumê. Endamtiya forûmê bi tevahî belaş e.

Python Bi Python Seleniumê Twîtter Bot

Zinar

Rêvebîr
Rêber
17 Mar 2020
33
Merheba hevalno. Bû du car vê mijarê ve dikim. Neyse em werin mijara xwe. Bi pirtûkxaneya Pythonê Selenium me botek ji bo twîtterê nivisand. Ev bot tenê niha dikare twît bavêje. Heta ku mezin bibe belkî karibe yekê jî bişopîne 😂

Python:
from selenium import webdriver
from userpass import username, password
import time
from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import sys

import unittest, time, re
from bs4 import BeautifulSoup as bs
from dateutil import parser
import pandas as pd
import itertools
import matplotlib.pyplot as plt

twitimiz = "Merheba hevalno ev twît ji aliyê bot hatiye avêtin."
#binary = FirefoxBinary('/usr/bin/firefox')
class Twitter:
    def __init__(self,username,password, twitimiz):
        self.browser = webdriver.Firefox()
        self.username = username
        self.password = password
        self.twitimiz = twitimiz
    def Giris(self):
        self.browser.get("https://twitter.com/login")
        time.sleep(2)
        self.browser.find_element_by_name("session[username_or_email]").send_keys(self.username)
        self.browser.find_element_by_name("session[password]").send_keys(self.password)
        time.sleep(1)
        self.browser.find_element_by_xpath("/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[3]/div/div").click()
        time.sleep(5)

    def Mesaj(self):
        self.browser.get("https://twitter.com/compose/tweet")
        self.browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div/div/div[1]/div/div/div/div[2]/div").send_keys(self.twitimiz)
        self.browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div[2]/div/div[3]/div/div/div/div[1]/div/div/div/div/div[2]/div[4]/div/div/div[2]/div[4]").click()

twt = Twitter(username,password,twitimiz,)
twt.Giris()
twt.Mesaj()

Ev împort hemû hewce nakin. Li ser dixebitim ji ber wî ewqas pirin. Tiştekî din jî di dosyaya userpass.py yê de divê têketina we ya twîtterê hebe
Kod:
username = "kurdtekno"
password = "şifreyaminaxweşik"


bimînin di xêr û xweşiyê de.