vulnhub下载
import bs4
import requests
# import logging
# logging.basicConfig(level=logging.DEBUG)
def search_items(keywork: str) -> list[str]:
resp = None
try:
resp = requests.get(url="https://vulnhub.com/?q={}".format(keywork))
soup = bs4.BeautifulSoup(resp.content.decode('utf-8'))
card_container = soup.find(attrs={'class': 'card-container'})
s = set()
t = filter(lambda x: x.find('entry') != -1,
[item['href'] for item in card_container.find_all('a')])
for i in t:
s.add('https://vulnhub.com' + i.split(sep='#')[0])
return list(s)
finally:
if resp != None:
resp.close()
def parse_page(url: str) -> list[str]:
resp = None
ret = []
try:
resp = requests.get(url=url)
soup = bs4.BeautifulSoup(resp.content.decode('utf-8'))
lst = soup.find(id='download').find_all('a')
for i in filter(lambda x: x.find('vulnhub') != -1, [item['href'] for item in lst]):
ret.append(i)
print(i)
finally:
if resp != None:
resp.close()
return ret
if __name__ == '__main__':
keyworks = [
'Kioptrix',
'funbox',
]
links = []
for i in keyworks:
for j in search_items(i):
ret = parse_page(j)
links.extend(ret)
for i in links:
print(i)