Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Implemented NoneType check for html parameter #55

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JannikSeuss
Copy link

Parameter html was assumed to be type of string. This is not always the case, therefore a check is implemented to prevent the application from crashing

I executed the following code and after a while it threw an error because the html parameter did not have the proper type.

tweetCriteria = got.manager.TweetCriteria().setQuerySearch('SEZ').setEmoji("unicode")
tweets = got.manager.TweetManager.getTweets(tweetCriteria)

Thrown Error:


AttributeError Traceback (most recent call last)

in ()
45 for st in searchterms:
46 tweetCriteria = got.manager.TweetCriteria().setQuerySearch(st).setEmoji("unicode")
---> 47 tweets = got.manager.TweetManager.getTweets(tweetCriteria)
48 ct = ct + 1
49 print('st number ' + str(ct))

1 frames

/usr/local/lib/python3.6/dist-packages/GetOldTweets3/manager/TweetManager.py in getTweets(tweetCriteria, receiveBuffer, bufferLength, proxy, debug)
86 tweet.username = usernames[0]
87 tweet.to = usernames[1] if len(usernames) >= 2 else None # take the first recipient if many
---> 88 rawtext = TweetManager.textify(tweetPQ("p.js-tweet-text").html(), tweetCriteria.emoji)
89 tweet.text = re.sub(r"\s+", " ", rawtext)
90 .replace('# ', '#').replace('@ ', '@').replace('$ ', '$')

/usr/local/lib/python3.6/dist-packages/GetOldTweets3/manager/TweetManager.py in textify(html, emoji)
182 # Step 1, prepare a single-line string for re convenience
183 puc = chr(0xE001)
--> 184 html = html.replace("\n", puc)
185
186 # Step 2, find images that represent emoji, replace them with the

AttributeError: 'NoneType' object has no attribute 'replace'

Parameter html was assumed to be type of string. This is not always the case, therefore a check is implemented to prevent the application from crashing
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant