forked from tasfik007/Barron-s-333-words-and-their-mnemonics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrap.py
34 lines (28 loc) · 921 Bytes
/
scrap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from bs4 import BeautifulSoup
import requests
import csv
csv_file = open('test.csv', 'w')
csv_writer = csv.writer(csv_file)
total_mn = 0
md = []
def getMnemonics(word, no_of_mnemonics):
global total_mn
global md
src = requests.get('https://mnemonicdictionary.com/?word='+word).text
data = BeautifulSoup(src, 'lxml')
for mnemonic in data.find_all('div', class_='card mnemonic-card'):
for content in mnemonic.find_all('div', class_='card-text'):
md.append(content.text)
print(md[total_mn])
total_mn = total_mn+1
if(total_mn >= no_of_mnemonics):
break
cd = ['\n ta', 'na']
getMnemonics('abase', 3)
print(type(md[0]))
a = 'Tasfik'
b = md[1]
c = md[2]
print(md[0].replace('\n', ''))
csv_writer.writerow(['Abase', 'Meaning', md[0].replace(
'\n', ''), md[1].replace('\n', ''), md[2].replace('\n', '')])