简体   繁体   English

尝试使用 Python 抓取 web 时出现“406 不可接受”

[英]Getting "406 Not Acceptable" when trying to scrape web using Python

I am new to Python and web scraping.我是 Python 和 web 抓取的新手。 I am trying to scrape articles from a website but getting "406 Not Acceptable" when I run this code.我试图从网站上抓取文章,但在运行此代码时收到“406 不可接受”。 Please help.请帮忙。

from requests import get
source_site_home_page = "https://www.readlightnovel.org/"
r = get(source_site_home_page)
print(r.text)

Add the user agent flags like in this thread: Python Requests HTTP Response 406在这个线程中添加用户代理标志: Python 请求 HTTP 响应 406

r.status_code gives you code 200 because the request was successful! r.status_code给你代码 200 因为请求成功了!

The contents of the page should be in r.text页面内容应该在r.text

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 python 对 web 进行缩放后出现“406 不可接受” - '406 Not Acceptable' after scaping web using python Python Web 抓取请求导致 406 错误 - Python Web Scrape Request resulting in a 406 Error Python - 网页抓取代码错误 - HTTP 错误 406:不可接受 - Python - Web Scraping Code Error - HTTP Error 406: Not Acceptable 初学者尝试使用 Python 和 BeautifulSoup 刮擦 web - A beginner trying to web scrape using Python and BeautifulSoup 使用 urlopen 时出现 HTTP 406 Not Acceptable 客户端错误 - HTTP 406 Not Acceptable client error when using urlopen 尝试使用 BS4 从 Trustpilot 抓取日期 web 时出现以下 JSON 错误 - Python - I am getting the following JSON error when trying to web scrape dates from Trustpilot with BS4 - Python 我正在尝试使用 python 和 BeautifulSoup 来 web 抓取 ebay,但我得到的列表索引超出范围错误 - I'm trying to web scrape ebay using python and BeautifulSoup, but I'm getting a list index out of rangeerror HTTP错误406:不可接受的Python urllib2 - HTTP Error 406: Not Acceptable Python urllib2 使用 python 刮取 web 页面 - Scrape web pages using python 使用Python进行网页抓取时汉字的矛盾编码规范 - Contradictory encoding specifications of Chinese characters when using Python to web scrape
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM