python-3.x - HTML-PARSING 并使用 python 从网页中获取链接
问题描述
我正在尝试从网页中收集所有网址,旨在对每个名称执行 NER 和传记。我一直在使用 html-parser。它给了我一些网址的链接,但它失败了,并且没有给出其他结果,我在没有给我结果的网址中发布了一对。
- ** https://ctinnovations.com/learn-about-connecticut-innovations/meet-our-team/
- 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 - 在数据框中搜索重复项(Python)
- sql - sql - pgAdmin4 .csv 导入失败
- d3.js - D3.js:如何从对象数组中选择第一个属性值?
- javascript - 如何从一个 (1.js) 文件中获取 json 格式数组到另一个 js 文件(2.js) 以最终在 html 中显示数据?
- postgresql - postgres 'only' 显示带有逗号分隔符的数字,即使数据保存时没有
- encoding - Content-Disposition 标头的编码错误(包含西里尔字母)UWP
- twitter-bootstrap - 可以使用 React-bootstrap 进行 PurgeCSS 吗?
- google-apps-script - onEdit 特定单元格将数据从一个谷歌表格复制到另一个
- git - 将文件添加到 git 的所有分支
- python - 有没有办法将超级对象变成子对象?