This commit is contained in:
parent
71ada753b1
commit
a0c4902702
1 changed files with 14 additions and 4 deletions
18
soup.py
18
soup.py
|
@ -7,9 +7,19 @@ from bs4 import BeautifulSoup
|
|||
|
||||
|
||||
|
||||
def re_link(link):
|
||||
urls = re.findall(r'href=[\'"]?([^\'" >]+)', link)
|
||||
return urls
|
||||
def get_node_link(node_contend: str):
|
||||
node_soup = BeautifulSoup(node_contend, "lxml")
|
||||
|
||||
temp_link = node_soup.find_all(name='a',class_='internal-link')
|
||||
node_link = set()
|
||||
for i in temp_link:
|
||||
i = i.get("href")
|
||||
|
||||
if i == "":
|
||||
continue
|
||||
|
||||
node_link.add(i)
|
||||
return node_link
|
||||
|
||||
|
||||
def new_section(soup):
|
||||
|
@ -59,7 +69,7 @@ def soup_link():
|
|||
break
|
||||
|
||||
node_id_link = '/' + file_name + '/#' +node_element["id"]
|
||||
node_dict["links"] = re_link(node_content)
|
||||
node_dict["links"] = get_node_link(node_content)
|
||||
node_dict["id-link"] = node_id_link
|
||||
node_dict["backlinks"] = []
|
||||
nodes_dict[node_element["id"]] = node_dict
|
||||
|
|
Loading…
Reference in a new issue