Python中文
首页
教程
问答
标签
搜索
登录
注册
状态码为200的链接重定向
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我有一个状态码为200的链接。但当我在浏览器中打开它时,它会重定向。在</p> <p>在用Python请求获取相同的链接时,它只显示原始链接中的数据。我尝试了Python请求和urllib,但是没有成功。在</p> <ol> <li><p>如何捕获最终的URL及其数据?</p></li> <li><p>状态为200的链接如何重定向?</p></li> </ol> <pre class="lang-none prettyprint-override"><code>>>> url ='http://www.afaqs.com/news/story/52344_The-target-is-to-get-advertisers-to-switch-from-print-to-TV-Ravish-Kumar-Viacom18' >>> r = requests.get(url) >>> r.url 'http://www.afaqs.com/news/story/52344_The-target-is-to-get-advertisers-to-switch-from-print-to-TV-Ravish-Kumar-Viacom18' >>> r.history [] >>> r.status_code 200 </code></pre> <p><a href="http://www.afaqs.com/news/story/52344_The-target-is-to-get-advertisers-to-switch-from-print-to-TV-Ravish-Kumar-Viacom18" rel="nofollow noreferrer">This is the link</a></p> <p><a href="http://www.afaqs.com/interviews/index.html?id=572_The-target-is-to-get-advertisers-to-switch-from-print-to-TV-Ravish-Kumar-Viacom18" rel="nofollow noreferrer">Redirected link</a></p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>这类url在script标记中是javascript代码。因此,python不会获取它们。在</p> <p>要获得链接,只需从它们各自的标记中提取它们。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
3 回答
如何在python中从数据帧列表中删除引号
2 回答
如何在python中从数据帧创建列表
8 回答
如何在Python中从数据帧创建嵌套的JSON
4 回答
如何在Python中从数据帧显示wordcloud
1 回答
如何在Python中从数据帧的时间戳中删除字符
9 回答
如何在Python中从数据帧绘制简单绘图?
4 回答
如何在python中从数据帧行提取具有特定长度的范围?
2 回答
如何在python中从数据帧设置dict中的值
2 回答
如何在Python中从数据库中获得一个结果
3 回答
如何在python中从数据框中绘制分类条形图
5 回答
如何在Python中从数据框中选择特定细节?
10 回答
如何在python中从数据集中删除unicode
5 回答
如何在python中从数据集中删除某些数值?
4 回答
如何在python中从数据集中选择行
8 回答
如何在Python中从数组中删除元素
2 回答
如何在python中从数组中删除单个倒逗号?
7 回答
如何在python中从数组中删除对象?
7 回答
如何在python中从数组中删除引号
2 回答
如何在python中从数组中删除所有最小值
7 回答