-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkaggle.py
39 lines (31 loc) · 922 Bytes
/
kaggle.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
import requests
from bs4 import BeautifulSoup
import re
def get_data(keyword):
keyword = ' '.join(keyword.split())
keyword = "kaggle corpus "+keyword
url = "https://www.google.com/search?q=" + keyword
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
s = str(soup)
s = s.replace("<b>","")
s = s.replace("</b>","")
url = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\), ]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', s)
link = ""
flag = 0
for i in url:
if "www.kaggle.com" in i:
link = i
tmp = ""
for j in link:
if j=='&':
break
tmp += j
flag = 1
link = tmp
if flag == 1:
break
return link + '/data'
if __name__ == '__main__':
keyword = 'homeless'
links_data = get_data(keyword)