-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniProt&Taxonomy_count.py
37 lines (33 loc) · 1.35 KB
/
UniProt&Taxonomy_count.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
from bs4 import BeautifulSoup
import requests
import json
from urllib.parse import urlencode
import re
class UniProtCount():
def __init__(self, keyword: str):
self.keyword = keyword
def get_info(self):
query_string = urlencode({'query':self.keyword})
query_url = 'https://www.uniprot.org/uniprot/?%s&sort=score' % query_string
response = requests.get(query_url)
bs = BeautifulSoup(response.content, features='html.parser')
result = int(re.findall("\d+",bs.find('div',class_='main-aside').find('script').text)[0])
return {
'title': 'UniProt',
'url': query_url,
'count':result,
}
class TaxonomyCount():
def __init__(self, keyword: str):
self.keyword = keyword
def get_info(self):
query_string = urlencode({'query': self.keyword})
query_url = 'https://www.uniprot.org/taxonomy/?%s&sort=score' % query_string
response = requests.get(query_url)
bs = BeautifulSoup(response.content, features='html.parser')
result = int(re.findall("\d+",bs.find('div',class_='main-aside').find('script').text)[0])
return {
'title': 'Taxonomy',
'url': query_url,
'count':result,
}