首页 > 解决方案 > HTML-PARSING 并使用 python 从网页中获取链接

问题描述

我正在尝试从网页中收集所有网址,旨在对每个名称执行 NER 和传记。我一直在使用 html-parser。它给了我一些网址的链接,但它失败了,并且没有给出其他结果,我在没有给我结果的网址中发布了一对。

  1. ** https://ctinnovations.com/learn-about-connecticut-innovations/meet-our-team/
  2. https://foundationcapital.com/our-team/* *

我的代码如下:—</p>

!pip install httplib2
import httplib2
from bs4 import BeautifulSoup, SoupStrainer

# EXTRACTING ALL WEB LINKS FROM A PARTICULAR WEBPAGE

j = vmsing_list.index(sourcefile)
print(j)
exturl = url_list[j][0]
print(exturl)
http = httplib2.Http()

response, content = http.request(exturl)

# STORING THE LINKS IN A LIST
links=[]

for link in BeautifulSoup(content).find_all('a', href=True):
    links.append(link['href'])
    
## AVAILING THE LINKS
p = range(len(links))
linklower =[]
for i in p :
    site = links[i].lower()
    linklower.append(site)
    print(linklower[i])
    #print(links)

我没有得到任何结果作为上述 URL 的输出。然而,对于许多 url,它在其他方面工作良好。

如果有人能告诉我什么应该是更好的代码来处理所有文件,我将不胜感激。

谢谢

标签: python-3.xurlnlphtml-parsingnamed-entity-recognition

解决方案


推荐阅读