File size: 1,628 Bytes
8413ddb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests
import streamlit as st
import streamlit.components.v1 as components
from requests_html import HTMLSession
from trafilatura import fetch_url , extract
import json



st.set_page_config('Scraping',":shark:","wide",menu_items={'About': "This is an *extremely* cool app!"})


menu=['Twitter','Trafilatura']
ch=st.sidebar.selectbox('Menu',menu)


if 'Trafilatura' in ch:
    with st.container():
        st.title('Trafilatura library')
        ti=st.text_input('Input url')
    if len(ti)>0:
        url = fetch_url(ti)
        x=extract(url,include_links=True,include_images=True)
        st.write(x)






url = "https://twitter135.p.rapidapi.com/Search/"
headers = {
	"X-RapidAPI-Key": "70652cf94dmsh09357b76b162df8p153fbajsn7e40a4b838cf",
	"X-RapidAPI-Host": "twitter135.p.rapidapi.com"
}

if 'Twitter' in ch:
    with st.container():
        st.title('Search key in Twitter')
        ti=st.text_input('Put Hashtag')
    if len(ti)>0:

        querystring = {"q":ti,"count":"20"}

        r=requests.get(url,headers=headers, params=querystring)
        x=r.json()
        options= x['globalObjects']['tweets']
        for i,j in options.items():
            st.success(j['created_at'])
            st.subheader(j['full_text'])
            st.write('---')

        '''
        response = requests.request("GET", url, headers=headers, params=querystring)
        x = response.text
        x= json.loads(x)
        options= x['globalObjects']['tweets']
        for k,v in options.items():
            st.success(v['created_at'])
            st.subheader(v['full_text'])
            st.write('---')
        '''