twitter刷评论是我们常用的营销手段,通过刷推特评论可以为你带来大量流量和潜在客户,还能够吸引客户购买你的商品,但是一条条去发评论感觉太繁琐了,这时候可以选择自动发twitter评论工具,下面为大家带来twitter(推特)自动评论代码。
功能大概就是自动留言的功能,代码比较机械简单。比较核心的代码在下面,有需要的朋友可以参考(当然还有一些,比如定位第一条推特啊,配置proxy一类的就自己琢磨吧!)
from getpass import getpass
import json
from selenium import webdriver
import time
import re
import random
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import requests
from fake_useragent import UserAgent
#第一步,储存登录,储存cookie
def login_twitter(username, password):
driver = webdriver.Chrome()
driver.get("https://twitter.com/login")
username_field = driver.find_element_by_name("session[username_or_email]")
password_field = driver.find_element_by_name("session[password]")
username_field.send_keys(username)
driver.implicitly_wait(1)
password_field.send_keys(password)
submit = driver.find_element_by_xpath("/html/body/div/div[2]/main/div/div/div[1]/form/div/div[3]/div/div")
submit.click()
f = open('/home/solin/tw.txt')#这里直接是网址了
a=f.readlines()
for name in a:
try:
username=name.strip('\n')
driver.get(username)
time.sleep(5)
chat=driver.find_element_by_css_selector("[aria-label='Reply']")
time.sleep(1)
chat.click()
send1=driver.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[2]/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/div/div/div')
send1.send_keys('Dear Sir/Madam. This is Delica Medical who is working on robotic-TCD for neuro ICU cerebral automatic monitoring and multimodal solutions. We have reference sites across Europe and USA.')
time.sleep(1)
sb1=driver.find_element_by_xpath('/html/body/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div[2]/div/div[3]/div/div/div/div[2]/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div')
sb1.click()
time.sleep(2)
username = name.strip('\n')
driver.get(username)
time.sleep(5)
chat = driver.find_element_by_css_selector("[aria-label='Reply']")
time.sleep(1)
chat.click()
send2 = driver.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[2]/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/div/div/div')
send2.send_keys('May we have the honor to send you the device publication and introduction per mail for further cooperation discussion? Our contact is info@delicasz.com; What is your hospital/institution and email contact?')
sb1 = driver.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[2]/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div')
sb1.click()
interval=random.randint(225, 300)
time.sleep(interval)
except:
pass
上面就是twitter(推特)自动评论代码的相关内容,希望大家可以喜欢。跨境电商服务有限公司提供twitter账号购买,twitter推特买粉丝,推特买点赞,油管账号出售,facebook账号购买等服务,欢迎咨询。