-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
48 lines (34 loc) · 1.36 KB
/
app.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
43
44
45
46
47
48
import requests
from bs4 import BeautifulSoup
url = "https://remoteintech.company/"
html = requests.get(url)
bs = BeautifulSoup(html.text, "lxml")
def get_all_companies_links():
""" Return a list of the companies url that accept remote jobs """
companies = bs.select('#companies-table tr')
links = []
for item in companies:
if item.find('td', class_='company-name'):
links.append(''.join([url[:-1], item.find('td', class_='company-name').find('a').get('href')]))
return links
def search_for_technology(key_word):
""" Return companies using the given technology """
links = get_all_companies_links()
results = []
for link in links:
print('finding on ...', link.split('/')[-2])
_html = requests.get(link)
bs = BeautifulSoup(_html.text, "lxml")
div = bs.find('div', class_='section-companyTechnologies')
text = div.find('p').text if div and div.find('p') else ''
if key_word.lower() in text.lower():
results.append(link)
print('** technology found! **', '\n')
return results
if __name__ == "__main__":
tech = input('Type a technology to be found: ')
result = search_for_technology(tech)
print('\n', '*** Results ***', '\n')
print('\n'.join([f'{idx}. {link}' for idx, link in enumerate(result)]))
print('\n','*** End ***')
pass