-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedlearn.py
43 lines (32 loc) · 909 Bytes
/
medlearn.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
35
36
37
38
39
40
41
42
#Author Robert Bikwemu
#
# Looking to test Machine Learning on Journal/Author/Keyword
# in scholarly publication.
#
#
import pubmed
import urllib2
from bs4 import BeautifulSoup
li=[]
_baseurl = 'http://www.ncbi.nlm.nih.gov/pubmed?term='
def search(term):
j=term.split(' ')
li=[]
l=[]
for i in range(len(j)):
h=len(j)-1
if i < h:
li.append(j[i]+'%20')
elif i==h:
li.append(j[i])
b=''
for i in range(len(li)):
b=b+li[i]
url=_baseurl+b
b=urllib2.urlopen(url)
soup=BeautifulSoup(b.read())
k=soup.findAll('p',{'class','title'})
for i in range(len(k)):
#first page of results with 20 links to articles at most
m=(k[i].find('a').get('href'))
l.append(m[8:])