Extend twitter.py script so each line includes tab-separated columns for each tweet:

Description

Extend the twitter.py script so that each line includes the following tab-separated columns for each tweet:

– Tweet text

– Number of comments (3 points)

– Number or retweets

– Number of Likes (3 points)

– Date (3 points)

from selenium import webdriver
import time,codecs
url=’https://twitter.com/SHAQ’
#open the browser and visit the url
driver = webdriver.Chrome(‘chromedriver.exe’)
driver.get(url)
#scroll down twice to load more tweets
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
time.sleep(2)
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
time.sleep(2)
#find all elements with a class that ends in ‘tweet-text’
tweets=driver.find_elements_by_css_selector(“[class*=original-tweet]”)
#write the tweets to a file
fw=codecs.open(‘tweets.txt’,’w’,encoding=’utf8′)
for tweet in tweets:
txt,retweets=’NA’,’NA’
try: txt=tweet.find_element_by_css_selector(“[class$=tweet-text]”).text
except: print (‘no text’)
try:
retweetElement=tweet.find_element_by_css_selector(“[class$=js-actionRetweet]”)
retweets=retweetElement.find_element_by_css_selector(‘[class=ProfileTweet-actionCountForPresentation]’).text
except:
print (‘no retweets’)
fw.write(txt.replace(‘n’,’ ‘)+’t’+str(retweets)+’n’)
fw.close()
driver.quit()#close the browser
esentation]’).text
from selenium import webdriver
import time,codecs
url=’https://twitter.com/SHAQ’
#open the browser and visit the url
driver = webdriver.Chrome(‘chromedriver.exe’)
driver.get(url)
#scroll down twice to load more tweets
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
time.sleep(2)
driver.execute_script(“window.scrollTo(0, document.body.scrollHeight);”)
time.sleep(2)
#find all elements with a class that ends in ‘tweet-text’
tweets=driver.find_elements_by_css_selector(“[class*=original-tweet]”)
#write the tweets to a file
fw=codecs.open(‘tweets.txt’,’w’,encoding=’utf8′)
for tweet in tweets:
txt,retweets=’NA’,’NA’
try: txt=tweet.find_element_by_css_selector(“[class$=tweet-text]”).text
except: print (‘no text’)
try:
retweetElement=tweet.find_element_by_css_selector(“[class$=js-actionRetweet]”)
retweets=retweetElement.find_element_by_css_selector(‘[class=ProfileTweet-actionCountForPresentation]’).text
except:
print (‘no retweets’)
fw.write(txt.replace(‘n’,’ ‘)+’t’+str(retweets)+’n’)
fw.close()
driver.quit()#close the browser
esentation]’).text

Purchase answer to see full
attachment

We offer the bestcustom writing paper services. We have done this question before, we can also do it for you.

Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.