Skip to content

Commit 42fe51d

Browse files
committed
add get_baike.py
1 parent 34742ff commit 42fe51d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spiderFile/get_baike.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import re
2+
import requests as rq
3+
4+
def get_baidubaike():
5+
6+
keyword = input('please input wordkey:')
7+
url = 'http://baike.baidu.com/item/{}'.format(keyword)
8+
html = rq.get(url).content.decode('utf-8')
9+
10+
regex = re.compile('content="(.*?)">')
11+
words = re.findall(regex, html)[0]
12+
return words
13+
14+
if __name__ == '__main__':
15+
words = get_baidubaike()
16+
print(words)
17+
18+
19+
20+

0 commit comments

Comments
 (0)