Commit ccc556a6 authored by Francesco Poldi's avatar Francesco Poldi

Scrape popular tweets

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