[fix] do not get external link for node
All checks were successful
/ deploy (push) Successful in 42s
All checks were successful
/ deploy (push) Successful in 42s
This commit is contained in:
parent
0d40891025
commit
9c4411eaa2
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):
|
def get_node_link(node_contend: str):
|
||||||
urls = re.findall(r'href=[\'"]?([^\'" >]+)', link)
|
node_soup = BeautifulSoup(node_contend, "lxml")
|
||||||
return urls
|
|
||||||
|
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):
|
def new_section(soup):
|
||||||
|
@ -59,7 +69,7 @@ def soup_link():
|
||||||
break
|
break
|
||||||
|
|
||||||
node_id_link = '/' + file_name + '/#' +node_element["id"]
|
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["id-link"] = node_id_link
|
||||||
node_dict["backlinks"] = []
|
node_dict["backlinks"] = []
|
||||||
nodes_dict[node_element["id"]] = node_dict
|
nodes_dict[node_element["id"]] = node_dict
|
||||||
|
|
Loading…
Reference in a new issue