[英]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.