import requests
import sys
from fake_useragent import UserAgent
from bs4 import BeautifulSoup as b
from concurrent.futures import ThreadPoolExecutor
sys.stdout = open("133000.txt", "wt")
user = UserAgent()
characters = list(map(str.strip, open('small_file_133000.txt').readlines()))
def function_name(character):
# proxies = {
#'http':
#['http://176.110.121.90:21776',
#'http://91.187.113.205:53281',
#'http://31.172.177.149:83',
#'http://116.90.229.186:35561',
#'http://103.83.118.10:55443',
#'http://116.73.14.16:80',
#'http://50.233.42.98:51696'],
#'https':
#['https://176.110.121.90:21776',
#'https://91.187.113.205:53281',
#'https://31.172.177.149:83',
# 'https://116.90.229.186:35561',
#'https://103.83.118.10:55443',
#'https://116.73.14.16:80',
# 'https://50.233.42.98:51696']
# }
chrome_ = user.random
header = {'User-Agent': chrome_}
url = f'https://en.m.wiktionary.org/wiki/{character}'
r = requests.get(url, headers=header)
soup = b(r.text, 'html.parser')
titlewik = soup.title.string
titlewik_final = titlewik.replace(" - Wiktionary", "")
find_main = soup.main
str_main = str(find_main)
final_main = str_main.replace("/wiki/", "entry://").replace("\n", "")
return titlewik_final + "\n<link rel='stylesheet' href='/CJK.css'>" + final_main + "\n</>"
with ThreadPoolExecutor() as executor:
for res in executor.map(function_name, characters):
print(res)
CJK-English Wiktionary 2021 (Python).zip (2.6 MB)
CJK.css (60.8 KB)
https://forum.freemdict.com/t/topic/6259
https://forum.freemdict.com/t/topic/6787
https://t.me/freemdict/153016