-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrohan.py
More file actions
executable file
·83 lines (72 loc) · 2.09 KB
/
rohan.py
File metadata and controls
executable file
·83 lines (72 loc) · 2.09 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from bs4 import BeautifulSoup
import urllib
import urllib.request
import re
import os
import csv
import re
import requests
import time
import urllib
import requests
import random
from tkinter import *
from random import choice
import math
import sys
import itertools
user_agents = [
'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
'Opera/9.25 (Windows NT 5.1; U; en)',
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
'Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.5 (like Gecko) (Kubuntu)',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9'
]
def make_soup(url):
req = urllib.request.Request(
url,
data=None,
headers={
'User-Agent': choice(user_agents)
}
)
data = urllib.request.urlopen(req)
soup = BeautifulSoup(data,'html.parser')
return soup
def isPrime(n):
if n==0:
return False
elif n==1:
print("Can't say!")
return
if n % 2 == 0 and n > 2:
return False
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
def mdict():
def Dict(event):
word = entry.get()
url = 'http://www.khandbahale.com/marathi-dictionary-translation-of-' + word
soup = make_soup(url)
let = 1
meaning = ''
for i in soup.findAll('div',{"class":"list-group"}):
if let == 1:
let =0;
continue
for j in i.findAll('a'):
# print(j.text.split()[2])
meaning = meaning + '\n' + j.text.split()[2]
break
res.configure(text = "Meaning: " + meaning)
w = Tk()
Label(w, text="Enter Word:").pack()
entry = Entry(w)
entry.bind("<Return>", Dict)
entry.pack()
res = Label(w)
res.pack()
w.mainloop()