Advertisement
Kotuara

Парсер всего словаря ожегова

Jul 6th, 2022
1,355
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None
  1. import requests
  2. from bs4 import BeautifulSoup
  3.  
  4. file_name = 'dicts/all.txt'
  5. file = open(file_name, 'w+')
  6. def get_new_words(url, file_name):
  7.     response = requests.get(url)
  8.     soup = BeautifulSoup(response.content.decode('windows-1251'), features="lxml")
  9.     quotes = soup.find_all('li')
  10.     for quote in quotes:
  11.         file.write(str(quote.text) + '\n')
  12.         print(quote.text)
  13.  
  14. for i in range(1,30):
  15.     url = 'https://onlinedic.net/ozhegov/letter' + str(i) + '.php'
  16.     get_new_words(url, file_name)
Advertisement
RAW Paste Data Copied
Advertisement