Commit 38a5cf9e authored by sashika sewwandi's avatar sashika sewwandi

Upload New File

parent 9d254642
Pipeline #5788 failed with stages
from __future__ import print_function
import twint
import pandas as pd
class Scrapdata():
def __init__(self):
self.page_link = None
self.quotes = []
self.zip_file_path = None
self.download_url = None
def create_download_url(self):
try:
c = twint.Config()
c.Search = ['Thor'] # topic
c.Limit = 10000 # number of Tweets to scrape
c.Store_csv = True # store tweets in a csv file
c.Output = "thor.csv" # path to csv file
twint.run.Search(c)
except Exception as e:
print("Can't scrape data from this site:", self.page_link)
print(e)
@staticmethod
def read_data(self):
try:
df = pd.read_csv('thor.csv')
print(df)
except Exception as e:
print("file read is unsuccessful")
print(e)
def invoke(self):
self.create_download_url()
self.read_data()
if __name__ == '__main__':
custom_driver_params = 'Create a new file WebScraping Twitter data'
new_file = Scrapdata()
new_file.invoke()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment