Skip to content

Instantly share code, notes, and snippets.

@zhullyb
Last active September 21, 2023 18:59
Show Gist options
  • Save zhullyb/e099c0ff6721ccfaca50530731efd4d0 to your computer and use it in GitHub Desktop.
Save zhullyb/e099c0ff6721ccfaca50530731efd4d0 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
url = 'https://toot.mantyke.icu/@dontworry'
def search(url, file):
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')
list_ = [i.string for i in soup.find_all('p')[1:-2]]
for i in list_:
file.write(i + '\n')
next_url = soup.find('a', class_='load-more', string='Show older')['href']
search(next_url, file)
with open('output.txt', 'w', encoding='utf-8') as file:
search(url, file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment