forked from conorsch/etym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
31 lines (31 loc) · 845 Bytes
/
test.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
# coding: utf-8
from BeautifulSoup import BeautifulSoup
import requests
query = 'viking'
r = requests.get("http://www.etymonline.com/index.php?search=" + query)
r.content
soup = BeautifulSoup(r.content, convertEntities=BeautifulSoup.HTML_ENTITIES)
soup
soup.dt.a.text
soup.dd
query = 'whale'
r = requests.get("http://www.etymonline.com/index.php?search=" + query)
soup = BeautifulSoup(r.content, convertEntities=BeautifulSoup.HTML_ENTITIES)
soup.dd
soup.dt.a.text
soup.dd
soup.dt
soup.dd
soup.dt
soup.dt()
soup.dd()
r.content
soup
soup.findAll('dd', { 'class': 'hightlight' } )
soup
soup.dd
[ x.a for x in soup.findAll('dt', { 'class': 'highlight' } ) ]
hits = [ x.a.text for x in soup.findAll('dt', { 'class': 'highlight' } ) ]
etyms = [ x.text for x in soup.findAll('dd', { 'class': 'highlight' } ) ]
results = zip(hits, etyms)
print(results)