【发布时间】:2019-12-26 07:04:44
【问题描述】:
澄清我的意思。这是 html 的样子:
我正在尝试使用此代码从突出显示的部分获取 href 链接。
from bs4 import BeautifulSoup as soup
from selenium import webdriver
driver = webdriver.Chrome("chromedriver.exe")
driver.get(r"http://wayback.archive.org/web/20101004060831/http://www.arcsoft.com:80/")
html = driver.page_source
page_soup = soup(html, "html.parser")
for i in page_soup.findAll("p", {"class": "impatient"}):
print(i.a['href'])
代码返回en-us/index.asp根据程序没有错误。但是当我点击页面源中的这个 href 链接时,它会将我重定向到具有完整链接的网站。
这是网站的最终网址:http://web.archive.org/web/20100227101719/http://www.arcsoft.com/en-us/index.asp
谁能帮我看看如何获得这个完整的网址?
【问题讨论】:
-
添加
a["href"]链接?http://web.archive.org/web/20100227101719/http://www.arcsoft.com/ + a["href"]
标签: html python-3.x beautifulsoup href