title: Python Detects URL and Removes It in Text File
body: <p>I have taken a Python script from <a href="https://stackoverflow.com/questions/52103888/by-beautiful-soup-i-scrape-twitter-data-i-am-able-to-get-data-but-cant-save-in">this</a> and edited it to fit my liking, where I print the first twenty Tweets from a particular page scraped to a text file.</p>
  
  <pre><code>from urllib.request import urlopen
  from bs4 import BeautifulSoup
  
  file = "tweets.txt"
  f = open(file, "w")
  url = "https://twitter.com/BBCWorld"
  html = urlopen(url)
  soup = BeautifulSoup(html, "html.parser")
  
  # Gets the tweet
  tweets = soup.find_all("li", attrs = {"class":"js-stream-item"})
  
  # Writes tweet fetched in file
  for tweet in tweets:
     try:
      if tweet.find('p',{'tweet-text'}):
         tweet_text = tweet.find('p',{'tweet-text'}).text.encode('utf8').strip()
         # tweet_user = tweet.find('span',{"class":'username'}).text.strip()
         # replies = tweet.find('span',{"class":"ProfileTweet-actionCount"}).text.strip()
         # retweets = tweet.find('span', {"class" : "ProfileTweet-action--retweet"}).text.strip()
         # String interpolation technique
         f.write(f'{tweet_text}\n')
    except: AttributeError
  f.close()
  </code></pre>
  
  <p>However, when the Tweets are printed there, they look like this (I'm using BBCWorld's feed as an example):</p>
  
  <pre><code>b'Van crash in south-east Iran kills 28 Afghan nationalshttps://bbc.in/2qcsg9P\xc2\xa0' 
  
  b'Guernsey asbestos cancer compensation scheme to launchhttps://bbc.in/2qQD9OE\xc2\xa0'
  
  b'Construction firm fined \xc2\xa310k for Jersey water pollutionhttps://bbc.in/2KgIk19\xc2\xa0'
  
  b'US election 2020: Deval Patrick announces presidential bidhttps://bbc.in/32QbdHH\xc2\xa0'
  
  b'Knottfield: Joseph Marshall indecent assault trial delayedhttps://bbc.in/2XcXYjg\xc2\xa0'
  
  b"Hugo Carvajal: Venezuelan ex-spy chief's disappearance 'a scandal'https://bbc.in/34VIwdY\xc2\xa0"
  
  b'What fate awaits those former members of Islamic State being expelled from Turkey?https://www.bbc.co.uk/news/50396607\xc2\xa0'
  
  b"Notre Dame: Army general tells architect to 'shut his mouth'https://bbc.in/2qVP7pX\xc2\xa0"
  
  b'Six years after a Boeing 737-500 crashed in Kazan, Russian investigators conclude that the pilot wasn\xe2\x80\x99t qualified to fly the plane &amp; had used falsified documents to get his job with (now defunct) Tatarstan Airlines. 50 people were killed.'
  
  b'South Africa rugby stars strip off for cancer challengehttps://bbc.in/2rJF2Nv\xc2\xa0'
  
  b"Diabetes: UN to tackle 'overly expensive' insulin priceshttps://bbc.in/2Op0nUf\xc2\xa0"
  
  b'US Senator blocks move to say Armenian mass killing was genocidehttps://bbc.in/2QfjjHr\xc2\xa0'
  
  b"Turkey to extradite American IS suspect 'stranded on border'https://bbc.in/33OJ1X1\xc2\xa0"
  
  b'Father and daughter ballet video breaks stereotypes, says teacherhttps://bbc.in/2KlFEPY\xc2\xa0'
  
  b'Australia seeks to curb foreign interference in universitieshttps://bbc.in/2NJcb4i\xc2\xa0'
  
  b'Washington teacher arrested for threatening to shoot studentshttps://bbc.in/2KlUk1o\xc2\xa0'
  
  b'Denmark holds neo-Nazi over Jewish cemetery attackhttps://bbc.in/2pjrcR9\xc2\xa0'
  
  b'Manus Island refugee author Behrouz Boochani arrives in New Zealandhttps://bbc.in/2NMI4cs\xc2\xa0'
  
  b'Italy to declare state of emergency over damage from Venice floodshttp://bbc.in/2OdDoeu\xc2\xa0'
  
  b'Condor Ferries bought by Swedish investment fundhttps://bbc.in/2NLw0rT\xc2\xa0'
  </code></pre>
  
  <p>How do I remove the "b's"? And, how can I make it so that I can remove the URL if the particular Tweet has that link, like all of these do?</p>
  
  <p>Additionally, why are there sometimes strings of numbers and letters that appear, and how can these be fixed/removed?</p>