xml - 请求在本地笔记本上工作,但在云笔记本上返回 403
问题描述
我在本地 jupyter notebook 上制作了一个 RSS 刮板,它正在工作,但是当我将它放入 Google Colab 时,我的一个 RSS 源出现 403 错误。退货内容如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<p>Additionally, a 403 Forbidden
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
为什么这只在我的云笔记本上?如何解决这个问题?
对于那些想要复制的人:
import requests
from bs4 import BeautifulSoup
rss = 'http://www.investimentosenoticias.com.br/noticias?format=feed'
r = requests.get(rss)
soup = BeautifulSoup(r.content, features='xml')
print(soup)
解决方案
推荐阅读
- javascript - 如何确保在 safari、firefox 和 chrome 中以相同方式处理 tinymce 5 编辑器区域的模糊事件?
- racket - 为什么我的函数总是返回一个空列表?
- java - 如何使用 ProcessLifecycleOwner 捕获生命周期事件?
- python - 带依赖项的 Siblig 导入
- typescript - TypeScript 3.5 中的直接或间接引用
- xamarin.forms - 在启动期间调用 Database.Migrate() 时崩溃
- actionresult - 方法内的 RedirectToAction 不起作用
- c# - C#如何修复文件到二进制到字符串到二进制转换期间的数据丢失
- python - 如何在每个组中查找一个字符串,然后比较其他列的值,然后将其存储在一个新的列中
- python - 类型错误:不支持的操作数类型 %:打印时为“NoneType”和“int”