【发布时间】:2021-02-12 06:25:33
【问题描述】:
我在尝试排除我漂亮的汤程序给出的结果时遇到问题,这是我的代码:
from bs4 import BeautifulSoup
import requests
URL = 'https://en.wikipedia.org/wiki/List_of_Wikipedia_mobile_applications'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
for link in soup.find_all('a'):
print(link.get('href'))
我不想得到以“#”开头的结果,例如:#cite_ref-18
我尝试过使用 for 循环,但收到以下错误消息:KeyError: 0
【问题讨论】:
标签: python beautifulsoup hyperlink python-requests screen-scraping