import requests
from bs4 import BeautifulSoup

r = requests.get("https://en.wikipedia.org/wiki/Main_Page")
data = r.text
soup = BeautifulSoup(data, "lxml")

filename = input("File to save to: ")

with open(filename, 'w') as f:
  for jump_link in soup.find_all(class_="mw-jump-link"): 
      if jump_link.a: 
          f.write(jump_link.a.text.replace("\n", " ").strip())
      else: 
          f.write(jump_link.contents[0].strip())
d8a0847b92caaac97ba15a2a31ec9ce3bca3ac0f
<mask token>

<mask token>
with open(filename, 'w') as f:
    for jump_link in soup.find_all(class_='mw-jump-link'):
        if jump_link.a:
            f.write(jump_link.a.text.replace('\n', ' ').strip())
        else:
            f.write(jump_link.contents[0].strip())

<mask token>
r = requests.get('https://en.wikipedia.org/wiki/Main_Page')
data = r.text
soup = BeautifulSoup(data, 'lxml')
filename = input('File to save to: ')
with open(filename, 'w') as f:
    for jump_link in soup.find_all(class_='mw-jump-link'):
        if jump_link.a:
            f.write(jump_link.a.text.replace('\n', ' ').strip())
        else:
            f.write(jump_link.contents[0].strip())

import requests
from bs4 import BeautifulSoup
r = requests.get('https://en.wikipedia.org/wiki/Main_Page')
data = r.text
soup = BeautifulSoup(data, 'lxml')
filename = input('File to save to: ')
with open(filename, 'w') as f:
    for jump_link in soup.find_all(class_='mw-jump-link'):
        if jump_link.a:
            f.write(jump_link.a.text.replace('\n', ' ').strip())
        else:
            f.write(jump_link.contents[0].strip())

import requests
from bs4 import BeautifulSoup

r = requests.get("https://en.wikipedia.org/wiki/Main_Page")
data = r.text
soup = BeautifulSoup(data, "lxml")

filename = input("File to save to: ")

with open(filename, 'w') as f:
  for jump_link in soup.find_all(class_="mw-jump-link"): 
      if jump_link.a: 
          f.write(jump_link.a.text.replace("\n", " ").strip())
      else: 
          f.write(jump_link.contents[0].strip())