Commit 65238708 authored by Francesco Poldi's avatar Francesco Poldi

Scrape popular tweets

parent 0d7a6f6f
......@@ -108,6 +108,7 @@ def initialize(args):
c.Retweets = args.retweets
c.Get_replies = args.get_replies
c.Custom_query = args.custom_query
c.Popular_tweets = args.popular_tweets
return c
def options():
......@@ -191,6 +192,7 @@ def options():
help="Automatically clean Pandas dataframe at every scrape.")
ap.add_argument("--get-replies", help="All replies to the tweet.", action="store_true")
ap.add_argument("-cq", "--custom-query", help="Custom search query.")
ap.add_argument("-pt", "--popular-tweets", help="Scrape popular tweets instead of recent ones.", action="store_true")
args = ap.parse_args()
return args
......
......@@ -63,4 +63,5 @@ class Config:
Hide_output = False
Get_replies = False
Near = ""
Custom_query = ""
\ No newline at end of file
Custom_query = ""
Popular_tweets = False
\ No newline at end of file
......@@ -59,8 +59,8 @@ async def Profile(username, init):
async def Search(config, init):
logme.debug(__name__+':Search')
url = f"{base}/search/timeline"
q = ""
params = [
('f', 'tweets'),
('vertical', 'default'),
('src', 'unkn'),
('include_available_features', '1'),
......@@ -68,7 +68,8 @@ async def Search(config, init):
('max_position', str(init)),
('reset_error_state', 'false'),
]
q = ""
if not config.Popular_tweets:
params.append(('f', 'tweets'))
if config.Lang:
params.append(("l", config.Lang))
params.append(("lang", "en"))
......
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