我在尝试从网页获取html内容时遇到问题。在
在这个网站:https://tmofans.com/library/manga/5763/nisekoi当你在“capitolo 230.00”中点击播放图标时,它打开下一个链接:https://tmofans.com/goto/347231会将你重定向到这个网站:https://tmofans.com/viewer/5c187dcea0240/paginated
问题是当你直接打开这个链接:https://tmofans.com/goto/347231页面给出了403禁止的消息。 重定向到最终页面的唯一方法是从第一页单击“播放”按钮。在
我想只使用tmofas.com/goto网站链接
我尝试使用请求和BeautifulSoup来获取html内容
import requests
from BeautifulSoup import BeautifulSoup
response = requests.get("https://tmofans.com/goto/347231")
page = str(BeautifulSoup(response.content))
print page
当我用https://tmofans.com/goto/347231执行此操作时,我只得到403禁止页的内容。在
这个网站检查你是否有他们网站的推荐人,否则会给你403的回复。通过设置一个referer,您可以轻松地绕过这个问题。在
输出
^{pr2}$有一次我用
http.client
和我的浏览器设法删除了一些受保护的页面。在我首先导航到需要访问的页面,然后使用浏览器的开发工具复制了请求标题并将其用于脚本中。这样,您的脚本将以浏览器访问资源的方式访问资源。在
这两种方法可以帮助您,首先解析HTTP请求以获取头文件(request和body可能也有帮助,具体取决于您的情况),然后使用第二种方法下载文件。在
这可能需要你做些调整才能奏效。在
标题字符串应如下所示:
^{pr2}$它可能会根据网站的不同而改变,但使用这些可以让我在登录后下载文件。在
相关问题 更多 >
编程相关推荐