@cache_control(no_cache=True, must_revalidate=True, no_store=True)
@login_required(login_url='login')
def tweetsPageView(request):
html_file{}
search = request.POST.get('searchtext')
# pass in the username of the account you want to download
page_id = search
#screen_name
flag = 0
now = datetime.datetime.now()
print("Data collected for time: ",now)
if os.path.isfile('tweeterScrapper.csv'):
with open('tweeterScrapper.csv', 'a',newline='') as f:
writer = csv.writer(f)
writer.writerow([" "," "])
writer.writerow(["","","",datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')])
for i in page_id:
collect_tweets_data(i)
time.sleep(1)
flag = 1
time.sleep(0)
else:
with open('tweeterScrapper.csv', 'w',newline='') as f:
writer = csv.writer(f)
writer.writerow(["Account", "#Tweets", "#Following", "#Followers", "#Likes", "#lists", "tweetid","url", "Data Collected","created_time", "Retweeted", "RetweetFrom","#likes","#retweets","texts","picture", "video","#Hashtag","links", "hashtag1", "hashtag2", "hashtag3", "hashtag4","hashtag5","link1", "link2","link3"])
for i in page_id:
collect_tweets_data(i)
time.sleep(1)
flag = 1
time.sleep(0)
# to read csv file named "samplee"
a = pd.read_csv("tweeterScrapper.csv")
#to save as html file
# named as "Table"
a.to_html("Table.htm")
# assign it to a
# variable (string)
html_file = a.to_html()
return render(request,'tweets.html',{'x':html_file})
# Я пытаюсь получить данные из входного тега в html с именем «поисковый текст» и передать их моему внутреннему интерфейсу, чтобы выполнить анализ в отдельном python скрипте и отобразить вывод, используя просмотров.