Modify call to get_rest_of_thread

This commit is contained in:
jeancf 2023-07-16 11:18:21 +02:00
parent f585878d0f
commit 9bdcccf713

View File

@ -169,12 +169,14 @@ Dowload page with full thread of tweets and extract all replied to tweet referen
Only used by `get_timeline()`. Only used by `get_timeline()`.
:param session: Existing HTTP session with Nitter instance :param session: Existing HTTP session with Nitter instance
:param headers: HTTP headers to use :param headers: HTTP headers to use
:param url: url of the thread page to download :param nitter url: url of the nitter instance to use
:param thread_url: url of the first tweet in thread
:return: List of tweets from the thread :return: List of tweets from the thread
""" """
def _get_rest_of_thread(session, headers, url): def _get_rest_of_thread(session, headers, nitter_url, thread_url):
logging.debug("Downloading tweets in thread from separate page") logging.debug("Downloading tweets in thread from separate page")
# Download page with thread # Download page with thread
url = nitter_url + thread_url
try: try:
thread_page = session.get(url, headers=headers, timeout=HTTPS_REQ_TIMEOUT) thread_page = session.get(url, headers=headers, timeout=HTTPS_REQ_TIMEOUT)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
@ -278,7 +280,7 @@ def get_timeline(nitter_url):
thread_link_tag = item.find('a', class_='tweet-link') thread_link_tag = item.find('a', class_='tweet-link')
if thread_link_tag is not None: if thread_link_tag is not None:
thread_url = thread_link_tag.get('href') thread_url = thread_link_tag.get('href')
timeline.extend(_get_rest_of_thread(session, headers, nitter_url + thread_url)) timeline.extend(_get_rest_of_thread(session, headers, nitter_url, thread_url))
else: else:
# Ignore other classes # Ignore other classes
continue continue